
CREATE TABLE admin (
  "passwort" varchar(20) DEFAULT '' NOT NULL,
  longpw varchar(255) DEFAULT '' NOT NULL,
  emailbetreff varchar(255) DEFAULT '' NOT NULL,
  emailtext text DEFAULT '' NOT NULL,
  emailadresse varchar(255) DEFAULT '' NOT NULL,
  emailname varchar(255) DEFAULT '' NOT NULL,
  mysqlshelluser varchar(25) DEFAULT '' NOT NULL,
  mysqlshellpasswort varchar(25) DEFAULT '' NOT NULL,
  mysqlshellhost varchar(255) DEFAULT '' NOT NULL,
  pop smallint DEFAULT 0 NOT NULL,
  email smallint DEFAULT 0 NOT NULL,
  autoresponder smallint DEFAULT 0 NOT NULL,
  ftp smallint DEFAULT 0 NOT NULL,
  subdomains smallint DEFAULT 0 NOT NULL,
  mysql smallint DEFAULT 0 NOT NULL,
  php smallint DEFAULT 1 NOT NULL,
  perl smallint DEFAULT 0 NOT NULL,
  modpython smallint DEFAULT 0 NOT NULL, -- if mod_python should be used
  ssi smallint DEFAULT 0 NOT NULL,
  cssl smallint DEFAULT 0 NOT NULL,
  frontpage smallint DEFAULT 0 NOT NULL,
  shell smallint DEFAULT 0 NOT NULL,
  statistik smallint DEFAULT 0 NOT NULL,
  pwschutz smallint DEFAULT 0 NOT NULL,
  fehlerseiten smallint DEFAULT 0 NOT NULL,
  webftp smallint DEFAULT 0 NOT NULL,
  webmail smallint DEFAULT 0 NOT NULL,
  phpmyadmin smallint DEFAULT 0 NOT NULL,
  phpmyadminpfad varchar(255) DEFAULT '' NOT NULL,
  lokaleips text DEFAULT '' NOT NULL,
  minuid int DEFAULT 2000 NOT NULL,
  maxuid int DEFAULT 1999 NOT NULL,
  quota smallint DEFAULT 0 NOT NULL,
  ftpmaxkb int DEFAULT 5120 NOT NULL,
  popmaxkb int DEFAULT 5120 NOT NULL,
  standardip varchar(15) NOT NULL,
  neukundenreload smallint DEFAULT 0 NOT NULL,
  indexcode text,
  indexfile varchar(30),
  mysqlshelluid int DEFAULT 0 NOT NULL,
  mysqlshellpasswortcrypt varchar(25) DEFAULT '' NOT NULL,
  mysqlshelllongpwcrypt varchar(255) DEFAULT '' NOT NULL,
  stdcgi smallint DEFAULT 0 NOT NULL,
  stddomain smallint DEFAULT 1 NOT NULL,
  flock int DEFAULT 0 NOT NULL,
  standarddomain varchar(255) DEFAULT '' NOT NULL,
  "language" varchar(2) DEFAULT 'de' NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  httpdspezial text DEFAULT '' NOT NULL,
  asp smallint DEFAULT 0 NOT NULL,
  wap smallint DEFAULT 0 NOT NULL,
  coldfusion smallint DEFAULT 0 NOT NULL,
  dirlist smallint DEFAULT 0 NOT NULL,
  login varchar(255) DEFAULT '' NOT NULL,
  ispemail varchar(255) DEFAULT '' NOT NULL,
  ispservername varchar(255) DEFAULT '' NOT NULL,
  isplastrun varchar(255) DEFAULT '' NOT NULL,
  httpdlogin text DEFAULT '' NOT NULL,
  phpupload smallint DEFAULT 0 NOT NULL, 
  dns smallint NOT NULL default 0,
  ip_pns varchar(255) NOT NULL default '',
  ip_sns varchar(255) NOT NULL default '',
  dnstemplate text NOT NULL,
  dnr smallint NOT NULL default 0,
  spamfilter smallint NOT NULL default 0,
  userprefix varchar(16) DEFAULT '' NOT NULL,
  -- flag: marks if confixx installation was postconfigured.
  postconf smallint DEFAULT 0 NOT NULL,
  hostname varchar(255) NOT NULL default '',
  business smallint NOT NULL default 0,
  checkupdates smallint NOT NULL default 0,
  cronjobs smallint NOT NULL default 0,
  majordomo smallint not null default 0,
  majordomohome varchar(255) not null default '',
  majordomoml varchar(255) not null default '',
  idn smallint not null default 0,
  scponly smallint not null default 0,
  oldskins smallint not null default 0,
 imap_options varchar(50) not null default ''
);

CREATE TABLE allgemein (
  quota smallint DEFAULT 0 NOT NULL,
  domains smallint DEFAULT 0 NOT NULL,
  newips smallint DEFAULT 1 NOT NULL,
  frontpage smallint DEFAULT 0 NOT NULL,
  perl smallint DEFAULT 0 NOT NULL,
  modpython smallint DEFAULT 0 NOT NULL, -- if mod_python should be used
  webalizer smallint DEFAULT 0 NOT NULL,
  lokaleips smallint DEFAULT 0 NOT NULL,
  deluser smallint DEFAULT 0 NOT NULL,
  delpop smallint DEFAULT 0 NOT NULL,
  delftp smallint DEFAULT 0 NOT NULL,
  adduser smallint DEFAULT 0 NOT NULL,
  addpop smallint DEFAULT 0 NOT NULL,
  addftp smallint DEFAULT 0 NOT NULL,
  htaccess smallint DEFAULT 0 NOT NULL,
  newpwd smallint DEFAULT 0 NOT NULL,
  webalizerpw smallint DEFAULT 0 NOT NULL,
  aliases smallint DEFAULT 0 NOT NULL,
  aliaseslr int DEFAULT 0 NOT NULL,
  aliasesupdate int DEFAULT 1 NOT NULL,
  httpd smallint DEFAULT 0 NOT NULL,
  httpdlr int DEFAULT 1 NOT NULL,
  httpdupdate int DEFAULT 0 NOT NULL,
  speicherlr int DEFAULT 1 NOT NULL,
  speicherupdate int DEFAULT 1 NOT NULL,
  ftptraffiklr int DEFAULT 1 NOT NULL,
  ftptraffikupdate int DEFAULT 0 NOT NULL,
  httpdtraffikupdate int DEFAULT 0 NOT NULL,
  httpdtraffiklr int DEFAULT 1 NOT NULL,
  lastrun int DEFAULT 0 NOT NULL,
  frontpageadd smallint DEFAULT 0 NOT NULL,
  frontpagedel smallint DEFAULT 0 NOT NULL,
  frontpagepw smallint DEFAULT 0 NOT NULL,
  fpaliasadd smallint DEFAULT 0 NOT NULL,
  fpaliasdel smallint DEFAULT 0 NOT NULL,
  newsletter smallint DEFAULT 0 NOT NULL,
  confixxupdate int DEFAULT 0 NOT NULL,
  frontpageemail smallint DEFAULT 0 NOT NULL,
  stdcgi smallint DEFAULT 0 NOT NULL,
  cssl smallint DEFAULT 0 NOT NULL,
  dns smallint NOT NULL default 0,
  spamupdate smallint DEFAULT 0 NOT NULL,
  cronupdate smallint DEFAULT 0 NOT NULL,
  checknewversion smallint DEFAULT 0 NOT NULL
);

CREATE TABLE anbieter (
  anbieter varchar(8) DEFAULT '' NOT NULL,
  passwort varchar(20) DEFAULT '' NOT NULL,
  longpw varchar(255) DEFAULT '' NOT NULL,
  maxkunden smallint DEFAULT 0 NOT NULL,
  maxkundenlimit smallint DEFAULT 0 NOT NULL,
  maxpop smallint DEFAULT 0 NOT NULL,
  maxpoplimit smallint DEFAULT 0 NOT NULL,
  maxkb int DEFAULT 0 NOT NULL,
  maxkblimit smallint DEFAULT 0 NOT NULL,
  maxmysql smallint DEFAULT 0 NOT NULL,
  maxmysqllimit smallint DEFAULT 0 NOT NULL,
  maxemail int DEFAULT 0 NOT NULL,
  maxemaillimit smallint DEFAULT 0 NOT NULL,
  maxftp int DEFAULT 0 NOT NULL,
  maxftplimit smallint DEFAULT 0 NOT NULL,
  maxtransfer int DEFAULT 0 NOT NULL,
  maxsubdomains int DEFAULT 0 NOT NULL,
  maxsubdomainslimit smallint DEFAULT 0 NOT NULL,
  maxwildcards int DEFAULT 0 NOT NULL,
  maxwildcardslimit smallint DEFAULT 0 NOT NULL, -- if limit is hard
  maxatdomains int DEFAULT 0 NOT NULL, -- maximum number of at domains
  maxatdomainslimit smallint DEFAULT 0 NOT NULL, -- if limit is hard
  maxautoresponder int DEFAULT 0 NOT NULL,
  maxautoresponderlimit smallint DEFAULT 0 NOT NULL,
  maxcronjobs int DEFAULT 0 NOT NULL,
  maxcronjobslimit smallint DEFAULT 0 NOT NULL,
  ftp smallint DEFAULT 0 NOT NULL,
  php smallint DEFAULT 0 NOT NULL,
  perl smallint DEFAULT 0 NOT NULL,
  modpython smallint DEFAULT 0 NOT NULL, -- if mod_python allowed
  ssi smallint DEFAULT 0 NOT NULL,
  cssl smallint DEFAULT 0 NOT NULL,
  shell smallint DEFAULT 0 NOT NULL,
  statistik smallint DEFAULT 0 NOT NULL,
  pwschutz smallint DEFAULT 0 NOT NULL,
  fehlerseiten smallint DEFAULT 0 NOT NULL,
  webftp smallint DEFAULT 0 NOT NULL,
  webmail smallint DEFAULT 0 NOT NULL,
  frontpage smallint DEFAULT 0 NOT NULL,
  anmeldedatum int NOT NULL,
  name varchar(255) DEFAULT '' NOT NULL,
  firma varchar(255) DEFAULT '' NOT NULL,
  anschrift varchar(255) DEFAULT '' NOT NULL,
  plzort varchar(255) DEFAULT '' NOT NULL,
  telefon varchar(255) DEFAULT '' NOT NULL,
  fax varchar(255) DEFAULT '' NOT NULL,
  emailadresse varchar(255) DEFAULT '' NOT NULL,
  kundennummer varchar(255) DEFAULT '' NOT NULL,
  freifeldname1 varchar(255) DEFAULT '' NOT NULL,
  freifeldwert1 varchar(255) DEFAULT '' NOT NULL,
  freifeldname2 varchar(255) DEFAULT '' NOT NULL,
  freifeldwert2 varchar(255) DEFAULT '' NOT NULL,
  freifeldname3 varchar(255) DEFAULT '' NOT NULL,
  freifeldwert3 varchar(255) DEFAULT '' NOT NULL,
  personendatenangeben smallint DEFAULT 0 NOT NULL,
  kundendatenanzeigen smallint DEFAULT 0 NOT NULL,
  kundendatenbeikundenanzeigen smallint DEFAULT 0 NOT NULL,
  emailbetreff varchar(255) DEFAULT '' NOT NULL,
  emailtext text DEFAULT '' NOT NULL,
  emailemailadresse varchar(255) DEFAULT '' NOT NULL,
  emailname varchar(255) DEFAULT '' NOT NULL,
  emailbcc varchar(255) DEFAULT '' NOT NULL,
  number int DEFAULT 0 NOT NULL,
  indexcode text,
  indexfile varchar(30),
  hilfecode text,
  stdcgi smallint DEFAULT 0 NOT NULL,
  gesperrt smallint DEFAULT 0 NOT NULL,
  maxdomains int DEFAULT '-1' NOT NULL,
  maxdomainslimit smallint DEFAULT 0 NOT NULL,
  standardip varchar(15) DEFAULT '' NOT NULL,
  httpdspezial text DEFAULT '' NOT NULL,
  "language" varchar(2) DEFAULT 'de' NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  ispemail varchar(255) DEFAULT '' NOT NULL,
  ispservername varchar(255) DEFAULT '' NOT NULL,
  isplastrun varchar(255) DEFAULT '' NOT NULL,
  asp smallint DEFAULT 0 NOT NULL,
  wap smallint DEFAULT 0 NOT NULL,
  coldfusion smallint DEFAULT 0 NOT NULL,
  dirlist smallint DEFAULT 0 NOT NULL,
  logcopy smallint DEFAULT 0 NOT NULL,
  phpupload smallint DEFAULT 0 NOT NULL,
  dbext smallint DEFAULT 0 NOT NULL,
  dns smallint NOT NULL default 0,
  pns varchar(255) NOT NULL default '',
  sns varchar(255) NOT NULL default '',
  dnsspezial text NOT NULL default '',
  dnr smallint NOT NULL default 0,
  gender varchar(255) NOT NULL default '',
  firstname varchar(255) NOT NULL default '',
  plz varchar(255) NOT NULL default '',
  land varchar(255) NOT NULL default '',
  spamfilter smallint NOT NULL default 0,
  maxidn int DEFAULT '0' NOT NULL,
  maxidnlimit smallint NOT NULL default 0,
  maxmaillist int DEFAULT '0' NOT NULL,
  maxmaillistlimit smallint NOT NULL default 0,
  scponly smallint not null default 0,
  custom_skins smallint DEFAULT 1 NOT NULL,
  PRIMARY KEY (anbieter)
);
-- CREATE SEQUENCE seq_angebote;
CREATE TABLE angebote (
  ident serial,
  name varchar(255) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  maxpop smallint DEFAULT 0 NOT NULL,
  maxkb int DEFAULT 0 NOT NULL,
  maxmysql smallint DEFAULT 0 NOT NULL,
  maxemail smallint DEFAULT 0 NOT NULL,
  maxautoresponder smallint DEFAULT 0 NOT NULL,
  maxftp smallint DEFAULT 0 NOT NULL,
  maxtransfer int DEFAULT 0 NOT NULL,
  maxsubdomains smallint DEFAULT 0 NOT NULL,
  maxcronjobs smallint DEFAULT 0 NOT NULL,
  ftp smallint DEFAULT 0 NOT NULL,
  php smallint DEFAULT 0 NOT NULL,
  wildcard smallint DEFAULT 0 NOT NULL,
  maxatdomains smallint DEFAULT 0 NOT NULL, -- maximum number of at domains
  perl smallint DEFAULT 0 NOT NULL,
  modpython smallint DEFAULT 0 NOT NULL, -- if mod_python allowed
  ssi smallint DEFAULT 0 NOT NULL,
  shell smallint DEFAULT 0 NOT NULL,
  statistik smallint DEFAULT 0 NOT NULL,
  pwschutz smallint DEFAULT 0 NOT NULL,
  fehlerseiten smallint DEFAULT 0 NOT NULL,
  webftp smallint DEFAULT 0 NOT NULL,
  webmail smallint DEFAULT 0 NOT NULL,
  emailbetreff varchar(255) DEFAULT '' NOT NULL,
  emailtext text DEFAULT '' NOT NULL,
  emailemailadresse varchar(255) DEFAULT '' NOT NULL,
  emailname varchar(255) DEFAULT '' NOT NULL,
  emailbcc varchar(255) DEFAULT '' NOT NULL,
  stdcgi smallint DEFAULT 0 NOT NULL,
  wap smallint DEFAULT 0 NOT NULL,
  coldfusion smallint DEFAULT 0 NOT NULL,
  phpupload smallint DEFAULT 0 NOT NULL,
  dirlist smallint DEFAULT 0 NOT NULL,
  asp smallint DEFAULT 0 NOT NULL,
  spamfilter smallint DEFAULT 0 NOT NULL,
  maxidn int DEFAULT '0' NOT NULL,
  maxmaillist int DEFAULT '0' NOT NULL,
  scponly smallint not null default 0,
  PRIMARY KEY (ident)
);
CREATE TABLE delaccs (
  account varchar(255) DEFAULT '' NOT NULL,
  "type" varchar(8) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  pfad varchar(255) DEFAULT '' NOT NULL
);
CREATE TABLE domains (
  "domain" varchar(255) DEFAULT '' NOT NULL unique,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  pfad varchar(255) DEFAULT '' NOT NULL,
  richtigedomain smallint DEFAULT 0 NOT NULL,
  cssl smallint DEFAULT 0 NOT NULL,
  frontpage smallint DEFAULT 0 NOT NULL,
  zusatz text DEFAULT '' NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  id serial,
  dns smallint default 0 not null,
  dnr smallint default 0 not null,
  primary key (id)
);

-- CREATE SEQUENCE seq_email;
CREATE TABLE email (
  ident serial,
  prefix varchar(65) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  pop3 varchar(255) DEFAULT '' NOT NULL,
  "domain" varchar(255) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  neu smallint DEFAULT 1 NOT NULL,
  pop3x text NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  PRIMARY KEY (ident)
);

--CREATE SEQUENCE seq_ereignisse;
CREATE TABLE ereignisse (
  ident serial,
  "timestamp" int DEFAULT 0 NOT NULL,
  nachricht varchar(255) DEFAULT '' NOT NULL,
  script varchar(255) DEFAULT '' NOT NULL,
  code smallint DEFAULT 0 NOT NULL,
  anbieter varchar(8) NOT NULL default '',
  kunde varchar(16) NOT NULL default '',
  geloescht smallint DEFAULT 0 NOT NULL,
  PRIMARY KEY (ident)
);

--CREATE SEQUENCE seq_fehlermeldungen;
CREATE TABLE fehlermeldungen (
  ident serial,
  pfad varchar(255) DEFAULT '' NOT NULL,
  fehlertyp int DEFAULT 0 NOT NULL,
  seite varchar(255) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  PRIMARY KEY (ident)
);
CREATE TABLE frontpage (
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  passwort varchar(12) DEFAULT '' NOT NULL,
  pw smallint DEFAULT 0 NOT NULL,
  neu smallint DEFAULT 1 NOT NULL,
  loeschen smallint DEFAULT 0 NOT NULL,
  "domain" varchar(255) DEFAULT '' NOT NULL,
  benutzer varchar(16) DEFAULT '' NOT NULL,
  email smallint DEFAULT 0 NOT NULL,
  emailadresse varchar(255) DEFAULT '' NOT NULL
);
CREATE TABLE frontpagealias (
  "domain" varchar(255) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  port smallint DEFAULT 0 NOT NULL,
  neu smallint DEFAULT 0 NOT NULL,
  loeschen smallint DEFAULT 0 NOT NULL
);
CREATE TABLE ftp (
  account varchar(16) DEFAULT '' NOT NULL,
  uid int DEFAULT 0 NOT NULL,
  passwort varchar(20) DEFAULT '' NOT NULL,
  longpw varchar(255) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  pfad varchar(255) DEFAULT '' NOT NULL,
  gesperrt smallint DEFAULT 0 NOT NULL,
  neu smallint DEFAULT 1 NOT NULL,
  pw smallint DEFAULT 0 NOT NULL,
  number int DEFAULT 0 NOT NULL,
  quota smallint DEFAULT 0 NOT NULL,
  maxkb int DEFAULT 0 NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  "language" varchar(2) DEFAULT 'de' NOT NULL,
  PRIMARY KEY (account)
);
CREATE TABLE grep (
  kunde varchar(16) DEFAULT '' NOT NULL,
  "type" varchar(8) DEFAULT '' NOT NULL,
  pattern varchar(255) DEFAULT '' NOT NULL
);

--CREATE SEQUENCE seq_htaccess;
CREATE TABLE htaccess (
  ident serial,
  pfad varchar(255) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  PRIMARY KEY (ident)
);
CREATE TABLE ipadressen (
  ip varchar(15) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  PRIMARY KEY (ip)
);

CREATE TABLE kunden (
  kunde varchar(16) DEFAULT '' NOT NULL,
  uid int DEFAULT 0 NOT NULL,
  passwort varchar(20) DEFAULT '' NOT NULL,
  longpw varchar(255) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  ip varchar(15) DEFAULT '' NOT NULL,
  maxpop smallint DEFAULT 0 NOT NULL,
  maxkb int DEFAULT 0 NOT NULL,
  kbhomedir int DEFAULT 0 NOT NULL,
  kbdb int DEFAULT 0 NOT NULL,
  kbpop int DEFAULT 0 NOT NULL,
  maxmysql smallint DEFAULT 0 NOT NULL,
  maxemail smallint DEFAULT 0 NOT NULL,
  maxautoresponder smallint DEFAULT 0 NOT NULL,
  maxftp smallint DEFAULT 0 NOT NULL,
  maxtransfer int DEFAULT 0 NOT NULL,
  maxsubdomains smallint DEFAULT 0 NOT NULL,
  maxatdomains smallint DEFAULT 0 NOT NULL, -- maximum number of at domains
  maxcronjobs smallint DEFAULT 0 NOT NULL,
  ftp smallint DEFAULT 0 NOT NULL,
  php smallint DEFAULT 0 NOT NULL,
  wildcard smallint DEFAULT 0 NOT NULL,
  perl smallint DEFAULT 0 NOT NULL,
  modpython smallint DEFAULT 0 NOT NULL, -- if mod_python allowed
  ssi smallint DEFAULT 0 NOT NULL,
  shell smallint DEFAULT 0 NOT NULL,
  statistik smallint DEFAULT 0 NOT NULL,
  statistikpasswort varchar(20) DEFAULT '' NOT NULL,
  statistiklongpw varchar(255) DEFAULT '' NOT NULL,
  pwschutz smallint DEFAULT 0 NOT NULL,
  fehlerseiten smallint DEFAULT 0 NOT NULL,
  webftp smallint DEFAULT 0 NOT NULL,
  webmail smallint DEFAULT 0 NOT NULL,
  kundendatenanzeigen smallint DEFAULT 0 NOT NULL,
  anmeldedatum int NOT NULL,
  name varchar(255) DEFAULT '' NOT NULL,
  firma varchar(255) DEFAULT '' NOT NULL,
  anschrift varchar(255) DEFAULT '' NOT NULL,
  plzort varchar(255) DEFAULT '' NOT NULL,
  telefon varchar(255) DEFAULT '' NOT NULL,
  fax varchar(255) DEFAULT '' NOT NULL,
  emailadresse varchar(255) DEFAULT '' NOT NULL,
  kundennummer varchar(255) DEFAULT '' NOT NULL,
  freifeldname1 varchar(255) DEFAULT '' NOT NULL,
  freifeldwert1 varchar(255) DEFAULT '' NOT NULL,
  freifeldname2 varchar(255) DEFAULT '' NOT NULL,
  freifeldwert2 varchar(255) DEFAULT '' NOT NULL,
  freifeldname3 varchar(255) DEFAULT '' NOT NULL,
  freifeldwert3 varchar(255) DEFAULT '' NOT NULL,
  anzahldateien int DEFAULT 0 NOT NULL,
  gesperrt smallint DEFAULT 0 NOT NULL,
  pw smallint DEFAULT 0 NOT NULL,
  neu smallint DEFAULT 1 NOT NULL,
  number int DEFAULT 0 NOT NULL,
  frontpage smallint DEFAULT 0 NOT NULL,
  quota smallint DEFAULT 0 NOT NULL,
  stdcgi smallint DEFAULT 0 NOT NULL,
  changedomains smallint DEFAULT 0 NOT NULL,
  hatalias smallint DEFAULT 0 NOT NULL,
  "language" varchar(2) DEFAULT 'de' NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  countdomains int DEFAULT 0 NOT NULL,
  httpdspezial text DEFAULT '' NOT NULL,
  asp smallint DEFAULT 0 NOT NULL,
  wap smallint DEFAULT 0 NOT NULL,
  coldfusion smallint DEFAULT 0 NOT NULL,
  dirlist smallint DEFAULT 0 NOT NULL,
  logcopy smallint DEFAULT 0 NOT NULL,
  phpupload smallint DEFAULT 0 NOT NULL, 
  gender varchar(255) NOT NULL default '',
  firstname varchar(255) NOT NULL default '',
  plz varchar(255) NOT NULL default '',
  land varchar(255) NOT NULL default '',
  spamfilter smallint DEFAULT 0 NOT NULL, 
  maxidn int DEFAULT 0 NOT NULL,
  list_size int DEFAULT 1 NOT NULL,
  maxmaillist int DEFAULT 0 NOT NULL,
  scponly smallint not null default 0,
  PRIMARY KEY (kunde)
);

CREATE TABLE logout (
  acc varchar(12) DEFAULT '' NOT NULL,
  logout smallint DEFAULT 0 NOT NULL,
  PRIMARY KEY (acc)
);
CREATE TABLE mysql_datenbanken (
  dbname varchar(19) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,  
  anbieter varchar(8) DEFAULT '' NOT NULL,
  datenbank int not null default 1,
  lastchange int DEFAULT 0 NOT NULL,
  dbext smallint DEFAULT 0 NOT NULL,
  PRIMARY KEY (dbname)
);
CREATE TABLE perl (
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(16) DEFAULT '' NOT NULL,
  loeschen smallint DEFAULT 0 NOT NULL,
  neu smallint DEFAULT 0 NOT NULL
);
CREATE TABLE pop3 (
  account varchar(16) DEFAULT '' NOT NULL,
  uid int DEFAULT 0 NOT NULL,
  passwort varchar(20) DEFAULT '' NOT NULL,
  longpw varchar(255) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(15) DEFAULT '' NOT NULL,
  gesperrt smallint DEFAULT 0 NOT NULL,
  neu smallint DEFAULT 1 NOT NULL,
  number int DEFAULT 0 NOT NULL,
  quota smallint DEFAULT 0 NOT NULL,
  maxkb int DEFAULT 0 NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  "language" varchar(2) DEFAULT 'de' NOT NULL,
  kommentar varchar(255) DEFAULT '' NOT NULL,
  auto_whitelist smallint DEFAULT 1 NOT NULL,
  spamfilter smallint DEFAULT 0 NOT NULL, 
  PRIMARY KEY (account)
);

--CREATE SEQUENCE seq_pwschutz;
CREATE TABLE pwschutz (
  ident serial,
  pfad varchar(255) DEFAULT '' NOT NULL,
  bereich varchar(255) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  PRIMARY KEY (ident)
);
CREATE TABLE transfer (
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  tag smallint DEFAULT 0 NOT NULL,
  monat smallint DEFAULT 0 NOT NULL,
  jahr smallint DEFAULT 0 NOT NULL,
  ftp int DEFAULT 0 NOT NULL,
  web int DEFAULT 0 NOT NULL,
  email int DEFAULT 0 NOT NULL,
  geloescht smallint DEFAULT 0 NOT NULL
);

--CREATE SEQUENCE seq_users;
CREATE TABLE users (
  ident serial,
  login varchar(35) DEFAULT '' NOT NULL,
  pass varchar(20) DEFAULT '' NOT NULL,
  longpw varchar(255) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  parent int DEFAULT 0 NOT NULL,
  PRIMARY KEY (ident)
);
CREATE TABLE webalizer (
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(16) DEFAULT '' NOT NULL,
  loeschen smallint DEFAULT 0 NOT NULL,
  neu smallint DEFAULT 0 NOT NULL
);
CREATE TABLE zeiten (
  httpdtraffikvon smallint DEFAULT 2 NOT NULL,
  httpdtraffikbis smallint DEFAULT 3 NOT NULL,
  httpdtraffiklast int DEFAULT 1 NOT NULL,
  httpdtraffikfreq smallint DEFAULT 120 NOT NULL,
  ftptraffikvon smallint DEFAULT 3 NOT NULL,
  ftptraffikbis smallint DEFAULT 4 NOT NULL,
  ftptraffiklast int DEFAULT 1 NOT NULL,
  ftptraffikfreq smallint DEFAULT 120 NOT NULL,
  speichervon smallint DEFAULT 4 NOT NULL,
  speicherbis smallint DEFAULT 5 NOT NULL,
  speicherfreq smallint DEFAULT 120 NOT NULL,
  speicherlast int DEFAULT 1 NOT NULL,
  httpdlpr int DEFAULT 0 NOT NULL,
  httpdfaktor int DEFAULT 1 NOT NULL,
  aliaseslpr int DEFAULT 0 NOT NULL,
  aliasesfaktor int DEFAULT 3 NOT NULL,
  confixxfaktor int DEFAULT 1 NOT NULL,
  checknewversion int DEFAULT 12 NOT NULL,
  maillistvon smallint default 0 not null,
  maillistbis  smallint default 24 not null,
  maillistfreq  int default 600 not null,
  maillistletzt int default 0 not null
);

CREATE TABLE domainlog (
  "domain" varchar(255) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  loeschen smallint DEFAULT 0 NOT NULL,
  neu smallint DEFAULT 0 NOT NULL
);

--CREATE SEQUENCE seq_nlinhalt;
CREATE TABLE nlinhalt (
  ident serial,
  mail text NOT NULL,
  von varchar(255) DEFAULT '' NOT NULL,
  PRIMARY KEY (ident)
);

--CREATE SEQUENCE seq_nladressen;
CREATE TABLE nladressen (
  ident serial,
  mailid int NOT NULL,
  emailadresse varchar(255),
  PRIMARY KEY (ident)
);
CREATE TABLE autoresponder (
  ident int NOT NULL,
  negvon smallint DEFAULT 0 NOT NULL,
  von varchar(255) DEFAULT '' NOT NULL,
  link smallint DEFAULT 0 NOT NULL,
  negrcpt smallint DEFAULT 0 NOT NULL,
  rcpt varchar(255) DEFAULT '' NOT NULL,
  absenderemail varchar(255) DEFAULT '' NOT NULL,
  absendername varchar(255) DEFAULT '' NOT NULL,
  emailbetreff varchar(255) DEFAULT '' NOT NULL,
  emailtext text NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  PRIMARY KEY (ident)
);
CREATE TABLE billing_del (
  date int NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  "type" varchar(255) NOT NULL,
  item varchar(255) NOT NULL
);           
CREATE TABLE billing_exp (
  "start" int NOT NULL,
  anbieter varchar(8) NOT NULL,
  email varchar(255) NOT NULL,
  modul varchar(255) NOT NULL
);
CREATE TABLE register (
  seriennummer varchar(255) DEFAULT '' NOT NULL,
  hwaddr varchar(255) DEFAULT '' NOT NULL,
  "version" varchar(255) DEFAULT '' NOT NULL,
  lizenz text DEFAULT '' NOT NULL,
  hinweis text DEFAULT '' NOT NULL,
  ip varchar(15) DEFAULT '' NOT NULL,
  ablauf varchar(255) DEFAULT '' NOT NULL,
  install smallint DEFAULT 0 NOT NULL,
  pw_root varchar(255) DEFAULT '' NOT NULL,
  pw_db_root varchar(255) DEFAULT '' NOT NULL,
  pw_db_user varchar(255) DEFAULT '' NOT NULL,
  pw_admin varchar(255) DEFAULT '' NOT NULL,
  logindomain varchar(255) DEFAULT '' NOT NULL,
  loginip varchar(15) DEFAULT '' NOT NULL,
  standarddomain varchar(255) DEFAULT '' NOT NULL,
  standardip varchar(15) DEFAULT '' NOT NULL,
  hostname varchar(255) DEFAULT '' NOT NULL
);
CREATE TABLE cssl (
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  privatekey text DEFAULT '' NOT NULL,
  crt text DEFAULT '' NOT NULL,
  csr text DEFAULT '' NOT NULL,
  neu smallint DEFAULT 0 NOT NULL,
  loeschen smallint DEFAULT 0 NOT NULL,
  aendern smallint DEFAULT 0 NOT NULL,
  countrycode varchar(4) DEFAULT '' NOT NULL,
  state varchar(255) DEFAULT '' NOT NULL,
  city varchar(255) DEFAULT '' NOT NULL,
  firm varchar(255) DEFAULT '' NOT NULL,
  unit varchar(255) DEFAULT '' NOT NULL,
  common varchar(255) DEFAULT '' NOT NULL,
  email varchar(255) DEFAULT '' NOT NULL,
  challenge varchar(255) DEFAULT '' NOT NULL,
  optional varchar(255) DEFAULT '' NOT NULL,
  PRIMARY KEY (kunde)
);

--CREATE SEQUENCE seq_webmail_ab;
CREATE TABLE webmail_ab (
  ident serial,
  pop3 varchar(16) DEFAULT '' NOT NULL,
  name varchar(255) DEFAULT '' NOT NULL,
  email varchar(255) DEFAULT '' NOT NULL,
  first_name varchar(255),
  last_name varchar(255),
  tel_home varchar(255),
  tel_work varchar(255),
  tel_mobile varchar(255),
  tel_fax varchar(255),
  address text,
  PRIMARY KEY (ident)
);

--CREATE SEQUENCE seq_webmail_session;
CREATE TABLE webmail_session (
  ident serial,
  pop3 varchar(16) DEFAULT '' NOT NULL,
  "password" varchar(20) DEFAULT '' NOT NULL,
  longpw varchar(255) DEFAULT '' NOT NULL,
  lang varchar(4) DEFAULT '' NOT NULL,
  "timestamp" timestamp,
  PRIMARY KEY (ident)
);

--CREATE SEQUENCE seq_webmail_sign;
CREATE TABLE webmail_sign (
  ident int serial,
  alias varchar(255) DEFAULT '' NOT NULL,
  pop3 varchar(255) DEFAULT '' NOT NULL,
  signatur text,
  PRIMARY KEY (ident)
);

--CREATE SEQUENCE seq_webmail_def_from;
CREATE TABLE webmail_def_from (
  ident serial,
  pop3 varchar(255) DEFAULT '' NOT NULL,
  email varchar(255) DEFAULT '' NOT NULL,
  PRIMARY KEY (ident)
);

--CREATE SEQUENCE seq_skins;
CREATE TABLE skins (
  cuser varchar(255) DEFAULT '' NOT NULL,
  skin varchar(255) DEFAULT '' NOT NULL,
  skin_id int DEFAULT 0 NOT NULL,
  PRIMARY KEY (cuser)
);

--CREATE SEQUENCE seq_dns;
CREATE TABLE dns (
  "domain" varchar(255) DEFAULT '' NOT NULL,
  kunde varchar(16) DEFAULT '' NOT NULL,
  anbieter varchar(8) DEFAULT '' NOT NULL,
  zonefile text NOT NULL,
  lastchange int DEFAULT 0 NOT NULL,
  neu smallint DEFAULT 0 NOT NULL,
  PRIMARY KEY ("domain")
);

CREATE TABLE restore (
  html varchar(255) DEFAULT '' NOT NULL,
  files varchar(255) DEFAULT '' NOT NULL,
  mysql varchar(255) DEFAULT '' NOT NULL,
  id serial,
  kunde varchar(16) not null default '',
  src varchar(255) DEFAULT '' NOT NULL,
  primary key(id)
);


CREATE TABLE backup (
  html varchar(255) DEFAULT '' NOT NULL,
  files varchar(255) DEFAULT '' NOT NULL,
  mysql varchar(255) DEFAULT '' NOT NULL,
  id serial,
  kunde varchar(16) not null default '',
  dst varchar(255) DEFAULT '' NOT NULL,
  primary key(id)
);

CREATE TABLE cronjobs (
  kunde       VARCHAR(16) DEFAULT '' NOT NULL,  
  cronfile    text DEFAULT '' NOT NULL,
  lastchange int NOT NULL DEFAULT 0,
  neu smallint NOT NULL DEFAULT 0,
  PRIMARY KEY (kunde)
);

CREATE TABLE custom_skins (
    id serial,
    name VARCHAR(255) NOT NULL DEFAULT '',      -- name of skin
    owner_type varchar(12) NOT NULL DEFAULT 'preinstalled',
    anbieter varchar(8) DEFAULT '' NOT NULL,    -- reseller
    show_name VARCHAR(255) NOT NULL DEFAULT '',  
    "version" VARCHAR(255) NOT NULL DEFAULT '',  
    "path" VARCHAR(255) NOT NULL DEFAULT '',  
    primary key(id)
);
-- the table stores preferences for SpamAssassin

CREATE TABLE spampref (
  username varchar(100) NOT NULL,        -- localpart of postbox address (localpart@domain)
  preference varchar(30) NOT NULL,
  value varchar(100) NOT NULL,
  prefid serial,
  primary key(prefid)
);
create index spampref_username on spampref(username);

-- the table stores default server for Business
CREATE TABLE bdefault (
  defaultserver bigint default NULL
);

-- the table stores default servers for Business
CREATE TABLE bmysql (
  keykerver serial,
  servername varchar(64) default NULL,
  ip varchar(64) default NULL,
  cuser varchar(64) default NULL,
  cpassword varchar(64) default NULL,
  port bigint default NULL,
  dbname varchar(64) default NULL,
  primary key (KeyServer)
);

create table maillist (
  id serial,
  name varchar(64) not null,
  domain_id int not null default 0,
  owner_mail varchar(255) not null,
  neu smallint default 1 not null,
  pwd varchar(32) default '' not null,
  gesperrt smallint DEFAULT 0 NOT NULL,
  quota smallint default 0 not null,
  primary key(id)
);

create table traffic ( 
  id serial,
  kunde varchar(16) not null, 
  anbieter varchar(8) not null,
  "year" smallint not null default 0, 
  "month" smallint not null default 0,
  "day" smallint not null default 0,
  sent bigint not null default 0, 
  received bigint  not null default 0,
  "local" smallint not null default 0, 
  maillist_id int not null default 0,
  primary key(id) 
);

CREATE TABLE updates (
  id serial,
  "version" varchar(50) not null,
  "type" varchar(30) not null,
  download_url varchar(255) not null,
  description_url varchar(255) not null,
  description_text text,
  release_date int not null default 0,
  "new" smallint not null default 1,
  primary key(id)
); 

create table idn_aliases (
  id serial,
  domain_id int references domains(id),
  idn_name varchar(255) default '' not null unique,
  charset varchar(32) default 'UTF8' not null,
  ascii_name varchar(255) default null unique,
  neu smallint not null default 1,
  primary key(id)
);

create table types ( 
  id serial,
  grp char(8) not null, 
  code char(16) not null default '',
  descr varchar(80),
  primary key(id) 
);

create table events ( 
  id serial,
  object_type int not null,
  object_id int,
  object_prop char(16) not null default '',
  event_type int not null,
  count int not null default 1,
  event int not null default 0,
  event_prop char(16) not null default '' ,
  primary key (id)	
);

create table bin (
  id serial,
  name varchar(64) not null unique,
  grp varchar(32) not null default '',
  "path" varchar(255),
  primary key (id)
);

CREATE TABLE iprestriction (
  id serial,
  ip varchar(15) not null default '',
  rest varchar(6) not null default 'accept',
  PRIMARY KEY (id)
);
	
CREATE TABLE sessions (
  id varchar(100) NOT NULL default '',
  startdate int NOT NULL default 0,
  lastupdate int NOT NULL default 0,
  sdata text NOT NULL,
  "user" varchar(255) NOT NULL default '',
  ip varchar(100) NOT NULL default '',
  PRIMARY KEY (id)
--  KEY lastupdate (lastupdate)
);
create index sessions_lastupdate on sessions(lastupdate);
			
CREATE TABLE pwdreminder (
  "user" varchar(16) NOT NULL default '',
  "password" varchar(255) NOT NULL default '',
  usertype smallint not null default 0,
  PRIMARY KEY  ("user","password")
);

CREATE TABLE atdomains (
  id serial, -- identifier
  name VARCHAR(255) DEFAULT '' NOT NULL, -- name of user
  id_from int , -- refers to domains.id, user will be redirected from this domain
  todomain VARCHAR(255) DEFAULT '' NOT NULL, -- user will be redirected to this domain
  PRIMARY KEY  (id),
  UNIQUE(name,id_from)
);

CREATE TABLE menublock (
  id serial, -- identifier
  label VARCHAR(255) DEFAULT '' NOT NULL, -- text that should be shown
  usertype varchar(8) NOT NULL default 'reseller', -- type of user
  PRIMARY KEY (id)
);

CREATE TABLE menuitem (
  id serial, -- identifier
  menublock_id int NOT NULL, -- refers to menublock.id
  label VARCHAR(255) DEFAULT '' NOT NULL, -- text that should be shown
  href VARCHAR(255) DEFAULT '' NOT NULL, -- href of menu
  in_frame SMALLINT NOT NULL DEFAULT 0,
  PRIMARY KEY (id)
);
