Location: PHPKode > projects > QuickTicket > quickticket/quickticket/install/qti_setup_3.php
<?php

// QuickTicket 1.9.0.3 build:20081001

session_start();

if ( isset($_SESSION['qti_setup_lang']) ) { $strLang = $_SESSION['qti_setup_lang']; } else { $strLang = 'en'; }
include('qti_lang_'.$strLang.'.php');
include('../bin/config.php');
include('../bin/qt_lib_db.php');

$strAppl = 'QuickTicket 1.9';
$strPrevUrl = 'qti_setup_2.php';
$strNextUrl = '../qti_usr_login.php?dfltname=Admin';
$strPrevLabel= $L['Back'];
$strNextLabel= $L['Finish'];
$strMessage = '';

// CHECK DB VERSION (in case of update)

$oDB = new cDB($qti_dbsystem,$qti_host,$qti_database,$qti_user,$qti_pwd,$qti_port,$qti_dsn);
if ( !empty($oDB->error) ) die ('<p style="color:red">Connection with database failed.<br/>Check that server is up and running.<br/>Check that the settings in the file <b>bin/config.php</b> are correct for your database.</p>');

$oDB->Query('SELECT setting FROM '.$qti_prefix.'qtisetting WHERE param="version"');
$row=$oDB->Getrow();

// UPDAGRADE TO 1.7

if ( $row['setting']!='1.7' && $row['setting']!='1.8' && $row['setting']!='1.9' )
{
  switch(substr($oDB->type,0,5))
  {
  case 'mysql':
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser MODIFY x decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser MODIFY y decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser MODIFY z decimal(13,2)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic MODIFY x decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic MODIFY y decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic MODIFY z decimal(13,2)');
    break;
  case 'mssql':
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN x decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN y decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN z decimal(13,2)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN x decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN y decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN z decimal(13,2)');
    break;
  case 'pg':
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN x TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN y TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN z TYPE decimal(13,2)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN x TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN y TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN z TYPE decimal(13,2)');
    break;
  case 'acces':
    // already float
    break;
  case 'sqlit':
    // already real
    break;
  case 'ibase':
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN x TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN y TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN z TYPE decimal(13,2)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN x TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN y TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN z TYPE decimal(13,2)');
    break;
  case 'db2':
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN x SET DATA TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN y SET DATA TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN z SET DATA TYPE decimal(13,2)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN x SET DATA TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN y SET DATA TYPE decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN z SET DATA TYPE decimal(13,2)');
    break;
  case 'ifx':
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser MODIFY (x decimal(13,10))');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser MODIFY (y decimal(13,10))');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser MODIFY (z decimal(13,2))');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic MODIFY (x decimal(13,10))');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic MODIFY (y decimal(13,10))');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic MODIFY (z decimal(13,2))');
    break;
  case 'oci':
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser MODIFY x decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser MODIFY y decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtiuser MODIFY z decimal(13,2)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic MODIFY x decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic MODIFY y decimal(13,10)');
    $oDB->Query('ALTER TABLE '.$qti_prefix.'qtitopic MODIFY z decimal(13,2)');
    break;
  }
  $oDB->Query('UPDATE '.$qti_prefix.'qtisetting SET setting="1.7" WHERE param="version"');
  if ( isset($qti_install) ) { define('QT','qti'.substr($qti_install,-1)); } else { define('QT','qti'); }
  $row['setting']='1.7';
  $strMessage .= '<p>Database upgraded to 1.7</p>';

}

// UPDAGRADE TO 1.8

if ( $row['setting']=='1.7' )
{
  $oDB->Query('UPDATE '.$qti_prefix.'qtisetting SET setting="1.8" WHERE param="version"');
  if ( isset($qti_install) ) { define('QT','qti'.substr($qti_install,-1)); } else { define('QT','qti'); }
  $row['setting']='1.8';
  $strMessage .= '<p>Database upgraded to 1.8</p>';
}

// UPDAGRADE TO 1.9

if ( $row['setting']=='1.8' )
{
  $oDB->Query( 'UPDATE '.$qti_prefix.'qtisetting SET param="index_name" WHERE param="forum_index_name"' );
  $oDB->Query( 'UPDATE '.$qti_prefix.'qtisetting SET param="section_desc" WHERE param="forum_descr"' );
  $oDB->Query( 'UPDATE '.$qti_prefix.'qtisetting SET param="sys_welcome" WHERE param="forum_welcome"' );
  if ( $oDB->type=='oci' ) $oDB->Query( 'UPDATE '.$qti_prefix.'qtisetting SET setting="4000" WHERE param="chars_per_post"' );

  switch($oDB->type)
  {

  case 'mysql4':

    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype varchar(10),
    objlang varchar(2),
    objid varchar(24),
    objname text,
    PRIMARY KEY (objtype,objlang,objid)
    )');
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic MODIFY COLUMN wisheddate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=REPLACE(wisheddate,"-","") WHERE wisheddate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=REPLACE(wisheddate,":","") WHERE wisheddate<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic MODIFY COLUMN firstpostdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=REPLACE(firstpostdate,"-","") WHERE firstpostdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=REPLACE(firstpostdate,":","") WHERE firstpostdate<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic MODIFY COLUMN lastpostdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=REPLACE(lastpostdate,"-","") WHERE lastpostdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=REPLACE(lastpostdate,":","") WHERE lastpostdate<>"0"' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost MODIFY COLUMN issuedate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost MODIFY COLUMN modifdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=REPLACE(issuedate,"-",""),modifdate=REPLACE(modifdate,"-","") WHERE modifdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=REPLACE(modifdate,"-",""),modifdate=REPLACE(modifdate,"-","") WHERE modifdate<>"0"' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser MODIFY COLUMN birthday VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser MODIFY COLUMN firstdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser MODIFY COLUMN lastdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET birthday=REPLACE(birthday,"-","") WHERE birthday<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=REPLACE(firstdate,"-","") WHERE firstdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=REPLACE(lastdate,"-","") WHERE lastdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=REPLACE(firstdate,":","") WHERE firstdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=REPLACE(lastdate,":","") WHERE lastdate<>"0"' );
    break;

  case 'mysql':
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype varchar(10),
    objlang varchar(2),
    objid varchar(24),
    objname varchar(4000),
    PRIMARY KEY (objtype,objlang,objid)
    )');
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic MODIFY COLUMN wisheddate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=REPLACE(wisheddate,"-","") WHERE wisheddate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=REPLACE(wisheddate,":","") WHERE wisheddate<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic MODIFY COLUMN firstpostdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=REPLACE(firstpostdate,"-","") WHERE firstpostdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=REPLACE(firstpostdate,":","") WHERE firstpostdate<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic MODIFY COLUMN lastpostdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=REPLACE(lastpostdate,"-","") WHERE lastpostdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=REPLACE(lastpostdate,":","") WHERE lastpostdate<>"0"' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost MODIFY COLUMN issuedate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost MODIFY COLUMN modifdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=REPLACE(issuedate,"-",""),modifdate=REPLACE(modifdate,"-","") WHERE modifdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=REPLACE(modifdate,"-",""),modifdate=REPLACE(modifdate,"-","") WHERE modifdate<>"0"' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser MODIFY COLUMN birthday VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser MODIFY COLUMN firstdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser MODIFY COLUMN lastdate VARCHAR(20) NOT NULL DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET birthday=REPLACE(birthday,"-","") WHERE birthday<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=REPLACE(firstdate,"-","") WHERE firstdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=REPLACE(lastdate,"-","") WHERE lastdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=REPLACE(firstdate,":","") WHERE firstdate<>"0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=REPLACE(lastdate,":","") WHERE lastdate<>"0"' );
    break;

  case 'mssql':
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype varchar(10),
    objlang varchar(2),
    objid varchar(24),
    objname varchar(4000),
    CONSTRAINT pk_'.$qti_prefix.'qtilang PRIMARY KEY (objtype,objlang,objid)
    )');

    // qtitopic

    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtitopic2 (
      id int NOT NULL CONSTRAINT pk_'.$qti_prefix.'qtitopic2 PRIMARY KEY,
      numid int NULL,
      forum int NULL,
      type char(1) NULL,
      status char(1) NULL,
      wisheddate varchar(20) NULL,
      firstpostid int NULL,
      lastpostid int NULL,
      firstpostuser int NULL,
      lastpostuser int NULL,
      firstpostname varchar(24) NULL,
      lastpostname varchar(24) NULL,
      firstpostdate varchar(20) NULL,
      lastpostdate varchar(20) NULL,
      actorid int NULL,
      actorname varchar(24) NULL,
      notifiedid int NULL,
      notifiedname varchar(24) NULL,
      x decimal(13,10) NULL,
      y decimal(13,10) NULL,
      z decimal(13,2) NULL,
      replies int NULL,
      views int NULL
      )' );
    $oDB->Query( 'INSERT INTO '.$qti_prefix.'qtitopic2 SELECT id,numid,forum,type,status,CONVERT(VARCHAR,wisheddate,112),firstpostid,lastpostid,firstpostuser,lastpostuser,firstpostname,lastpostname,CONVERT(VARCHAR,firstpostdate,120),CONVERT(VARCHAR,lastpostdate,120),actorid,actorname,notifiedid,notifiedname,x,y,z,replies,views FROM '.$qti_prefix.'qtitopic' );
    $oDB->Query( 'DROP TABLE '.$qti_prefix.'qtitopic' );
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtitopic (
      id int NOT NULL CONSTRAINT pk_'.$qti_prefix.'qtitopic PRIMARY KEY,
      numid int NULL default 0,
      forum int NULL default 0,
      type char(1) NULL default "T",
      status char(1) NULL default "0",
      wisheddate varchar(20) NULL default "0",
      firstpostid int NULL default 0,
      lastpostid int NULL default 0,
      firstpostuser int NULL default 0,
      lastpostuser int NULL default 0,
      firstpostname varchar(24) NULL,
      lastpostname varchar(24) NULL,
      firstpostdate varchar(20) NULL default "0",
      lastpostdate varchar(20) NULL default "0",
      actorid int NULL,
      actorname varchar(24) NULL,
      notifiedid int NULL,
      notifiedname varchar(24) NULL,
      x decimal(13,10) NULL,
      y decimal(13,10) NULL,
      z decimal(13,2) NULL,
      replies int NULL default 0,
      views int NULL default 0
      )' );
    $oDB->Query( 'INSERT INTO '.$qti_prefix.'qtitopic SELECT * FROM '.$qti_prefix.'qtitopic2' );
    $oDB->Query( 'DROP TABLE '.$qti_prefix.'qtitopic2' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=REPLACE(firstpostdate,"-","") WHERE firstpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=REPLACE(firstpostdate,":","") WHERE firstpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=REPLACE(lastpostdate,"-","") WHERE lastpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=REPLACE(lastpostdate,":","") WHERE lastpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate="0" WHERE wisheddate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate="0" WHERE firstpostdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate="0" WHERE lastpostdate IS NULL' );

    // qtipost

    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtipost2 (
      id int NOT NULL CONSTRAINT pk_'.$qti_prefix.'qtipost2 PRIMARY KEY,
      forum int NULL,
      topic int NULL,
      icon char(2) NULL,
      title varchar(64) NULL,
      type char(1) NULL,
      userid int NULL,
      username varchar(24) NULL,
      issuedate varchar(20) NULL,
      modifdate varchar(20) NULL,
      modifuser int NULL,
      modifname varchar(24) NULL,
      attach varchar(255) NULL,
      textmsg text
      )' );
    $oDB->Query( 'INSERT INTO '.$qti_prefix.'qtipost2 SELECT id,forum,topic,icon,title,type,userid,username,CONVERT(VARCHAR,issuedate,120),CONVERT(VARCHAR,modifdate,120),modifuser,modifname,attach,textmsg FROM '.$qti_prefix.'qtipost' );
    $oDB->Query( 'DROP TABLE '.$qti_prefix.'qtipost' );
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtipost (
    id int NOT NULL CONSTRAINT pk_'.$qti_prefix.'qtipost PRIMARY KEY,
    forum int NOT NULL default 0,
    topic int NOT NULL default 0,
    icon char(2) NOT NULL default "00",
    title varchar(64) NULL,
    type char(1) NOT NULL default "R",
    userid int NOT NULL default 0,
    username varchar(24) NULL,
    issuedate varchar(20) NULL default "0",
    modifdate varchar(20) NULL default "0",
    modifuser int NULL,
    modifname varchar(24) NULL,
    attach varchar(255) NULL,
    textmsg text)' );
    $oDB->Query( 'INSERT INTO '.$qti_prefix.'qtipost SELECT * FROM '.$qti_prefix.'qtipost2' );
    $oDB->Query( 'DROP TABLE '.$qti_prefix.'qtipost2' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=REPLACE(issuedate,"-","") WHERE issuedate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=REPLACE(issuedate,":","") WHERE issuedate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=REPLACE(modifdate,"-","") WHERE modifdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=REPLACE(modifdate,":","") WHERE modifdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate="0" WHERE issuedate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate="0" WHERE modifdate IS NULL' );

    // qtiuser

    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtiuser2 (
      id int NOT NULL CONSTRAINT pk_'.$qti_prefix.'qtiuser2 PRIMARY KEY,
      name varchar(24) NULL,
      closed char(1) NULL,
      role char(1) NULL,
      pwd varchar(40) NULL,
      www varchar(64) NULL,
      mail varchar(64) NULL,
      phone varchar(64) NULL,
      privacy char(1) NULL,
      location varchar(24) NULL,
      firstdate varchar(20) NULL,
      lastdate varchar(20) NULL,
      birthday varchar(20) NULL,
      numpost int NULL,
      signature varchar(255) NULL,
      avatar varchar(4) NULL,
      children char(1) NULL,
      parentmail varchar(64) NULL,
      parentagree char(1) NULL,
      x decimal(13,10) NULL,
      y decimal(13,10) NULL,
      z decimal(13,2) NULL,
      ip varchar(24) NULL
      )' );

    $oDB->Query( 'INSERT INTO '.$qti_prefix.'qtiuser2 SELECT id,name,closed,role,pwd,www,mail,phone,privacy,location,CONVERT(VARCHAR,firstdate,120),CONVERT(VARCHAR,lastdate,120),CONVERT(VARCHAR,birthday,112),numpost,signature,avatar,children,parentmail,parentagree,x,y,z,ip FROM '.$qti_prefix.'qtiuser' );
    $oDB->Query( 'DROP TABLE '.$qti_prefix.'qtiuser' );
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtiuser (
    id int NOT NULL CONSTRAINT pk_'.$qti_prefix.'qtiuser PRIMARY KEY,
    name varchar(24) NOT NULL CONSTRAINT uk_'.$qti_prefix.'qtiuser UNIQUE,
    closed char(1) NULL default "0",
    role char(1) NULL default "V",
    pwd varchar(40) NULL,
    www varchar(64) NULL,
    mail varchar(64) NULL,
    phone varchar(64) NULL,
    privacy char(1) NOT NULL default "1",
    location varchar(24) NULL,
    firstdate varchar(20) NULL default "0",
    lastdate varchar(20) NULL default "0",
    birthday varchar(20) NULL,
    numpost int NULL,
    signature varchar(255) NULL,
    avatar varchar(4) NULL,
    children char(1) NULL default "0",
    parentmail varchar(64) NULL,
    parentagree char(1) NULL,
    x decimal(13,10) NULL,
    y decimal(13,10) NULL,
    z decimal(13,2) NULL,
    ip varchar(24) NULL)'
    );
    $oDB->Query( 'INSERT INTO '.$qti_prefix.'qtiuser SELECT * FROM '.$qti_prefix.'qtiuser2' );
    $oDB->Query( 'DROP TABLE '.$qti_prefix.'qtiuser2' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=REPLACE(firstdate,"-","") WHERE firstdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=REPLACE(firstdate,":","") WHERE firstdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=REPLACE(lastdate,"-","") WHERE lastdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=REPLACE(lastdate,":","") WHERE lastdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET birthday="0" WHERE birthday IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate="0" WHERE firstdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate="0" WHERE lastdate IS NULL' );

    break;

  case 'pg':

    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype varchar(10),
    objlang varchar(2),
    objid varchar(24),
    objname varchar(4000),
    PRIMARY KEY (objtype,objlang,objid)
    )');
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN wisheddate TYPE VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=REPLACE(wisheddate,"-","") WHERE wisheddate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=SUBSTRING(wisheddate,1,8) WHERE wisheddate IS NOT NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN firstpostdate TYPE VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=REPLACE(firstpostdate,"-","") WHERE firstpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=REPLACE(firstpostdate,":","") WHERE firstpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=SUBSTRING(firstpostdate,1,15) WHERE firstpostdate IS NOT NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ALTER COLUMN lastpostdate TYPE VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=REPLACE(lastpostdate,"-","") WHERE lastpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=REPLACE(lastpostdate,":","") WHERE lastpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=SUBSTRING(lastpostdate,1,15) WHERE lastpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate="0" WHERE wisheddate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate="0" WHERE firstpostdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate="0" WHERE lastpostdate IS NULL' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ALTER COLUMN issuedate TYPE VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=REPLACE(issuedate,"-","") WHERE issuedate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=REPLACE(issuedate,":","") WHERE issuedate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=SUBSTRING(issuedate,1,15) WHERE issuedate IS NOT NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ALTER COLUMN modifdate TYPE VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=REPLACE(modifdate,"-","") WHERE modifdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=REPLACE(modifdate,":","") WHERE modifdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=SUBSTRING(modifdate,1,15) WHERE modifdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate="0" WHERE issuedate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate="0" WHERE modifdate IS NULL' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN birthday TYPE VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET birthday=REPLACE(birthday,"-","") WHERE birthday IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET birthday=SUBSTRING(birthday,1,8) WHERE birthday IS NOT NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN firstdate TYPE VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=REPLACE(firstdate,"-","") WHERE firstdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=REPLACE(firstdate,":","") WHERE firstdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=SUBSTRING(firstdate,1,15) WHERE firstdate IS NOT NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ALTER COLUMN lastdate TYPE VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=REPLACE(lastdate,"-","") WHERE lastdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=REPLACE(lastdate,":","") WHERE lastdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=SUBSTRING(lastdate,1,15) WHERE lastdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET birthday="0" WHERE birthday IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate="0" WHERE firstdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate="0" WHERE lastdate IS NULL' );

    break;

  case 'sqlite':
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype text,
    objlang text,
    objid text,
    objname text,
    PRIMARY KEY (objtype,objlang,objid)
    )' );
    break;

  case 'ibase':
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype varchar(10),
    objlang varchar(2),
    objid varchar(24),
    objname varchar(4000),
    PRIMARY KEY (objtype,objlang,objid)
    )' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD tempcol VARCHAR(50) DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=( (EXTRACT(YEAR FROM wisheddate)*10000)+(EXTRACT(MONTH FROM wisheddate)*100)+EXTRACT(DAY FROM wisheddate) ) WHERE wisheddate IS NOT NULL' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP wisheddate' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD wisheddate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=SUBSTRING(tempcol FROM 1 FOR 8) WHERE tempcol<>"0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol="0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=( (EXTRACT(YEAR FROM firstpostdate)*10000)+(EXTRACT(MONTH FROM firstpostdate)*100)+EXTRACT(DAY FROM firstpostdate) ) || " " || ( (EXTRACT(HOUR FROM firstpostdate)*10000)+(EXTRACT(MINUTE FROM firstpostdate)*100)+EXTRACT(SECOND FROM firstpostdate) ) WHERE firstpostdate IS NOT NULL' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP firstpostdate' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD firstpostdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol="0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=( (EXTRACT(YEAR FROM lastpostdate)*10000)+(EXTRACT(MONTH FROM lastpostdate)*100)+EXTRACT(DAY FROM lastpostdate) ) || " " || ( (EXTRACT(HOUR FROM lastpostdate)*10000)+(EXTRACT(MINUTE FROM lastpostdate)*100)+EXTRACT(SECOND FROM lastpostdate) ) WHERE lastpostdate IS NOT NULL' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP lastpostdate' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD lastpostdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP tempcol' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD tempcol VARCHAR(50) DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET tempcol=( (EXTRACT(YEAR FROM issuedate)*10000)+(EXTRACT(MONTH FROM issuedate)*100)+EXTRACT(DAY FROM issuedate) ) || " " || ( (EXTRACT(HOUR FROM issuedate)*10000)+(EXTRACT(MINUTE FROM issuedate)*100)+EXTRACT(SECOND FROM issuedate) ) WHERE issuedate IS NOT NULL' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP issuedate' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD issuedate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET tempcol="0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET tempcol=( (EXTRACT(YEAR FROM modifdate)*10000)+(EXTRACT(MONTH FROM modifdate)*100)+EXTRACT(DAY FROM modifdate) ) || " " || ( (EXTRACT(HOUR FROM modifdate)*10000)+(EXTRACT(MINUTE FROM modifdate)*100)+EXTRACT(SECOND FROM modifdate) ) WHERE modifdate IS NOT NULL' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP modifdate' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD modifdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP tempcol' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD tempcol VARCHAR(50) DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET tempcol=( (EXTRACT(YEAR FROM firstdate)*10000)+(EXTRACT(MONTH FROM firstdate)*100)+EXTRACT(DAY FROM firstdate) ) || " " || ( (EXTRACT(HOUR FROM firstdate)*10000)+(EXTRACT(MINUTE FROM firstdate)*100)+EXTRACT(SECOND FROM firstdate) ) WHERE firstdate IS NOT NULL' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP firstdate' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD firstdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=SUBSTRING(tempcol FROM 1 FOR 15)' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET tempcol="0"' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET tempcol=( (EXTRACT(YEAR FROM lastdate)*10000)+(EXTRACT(MONTH FROM lastdate)*100)+EXTRACT(DAY FROM lastdate) ) || " " || ( (EXTRACT(HOUR FROM lastdate)*10000)+(EXTRACT(MINUTE FROM lastdate)*100)+EXTRACT(SECOND FROM lastdate) ) WHERE lastdate IS NOT NULL' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP lastdate' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD lastdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP tempcol' );
    break;

  case 'access':
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype varchar(10),
    objlang varchar(2),
    objid varchar(24),
    objname memo,
    CONSTRAINT pk_'.$qti_prefix.'qtilang PRIMARY KEY (objtype,objlang,objid)
    )');
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD COLUMN tempcol VARCHAR(50)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=Format(wisheddate,"yyyymmdd")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP COLUMN wisheddate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD COLUMN wisheddate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=Format(firstpostdate,"yyyymmdd")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP COLUMN firstpostdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD COLUMN firstpostdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=Format(lastpostdate,"yyyymmdd")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP COLUMN lastpostdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD COLUMN lastpostdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=tempcol' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP COLUMN tempcol' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD COLUMN tempcol VARCHAR(50)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET tempcol=Format(issuedate,"yyyymmdd")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP COLUMN issuedate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD COLUMN issuedate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET tempcol=Format(modifdate,"yyyymmdd")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP COLUMN modifdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD COLUMN modifdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=tempcol' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP COLUMN tempcol' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD COLUMN tempcol VARCHAR(50)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET tempcol=Format(firstdate,"yyyymmdd")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP COLUMN firstdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD COLUMN firstdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=MID(tempcol,1,20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET tempcol=Format(lastdate,"yyyymmdd")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP COLUMN lastdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD COLUMN lastdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=MID(tempcol,1,20)' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP COLUMN tempcol' );
    break;

  case 'db2':
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype varchar(10),
    objlang varchar(2),
    objid varchar(24),
    objname varchar(4000),
    PRIMARY KEY (objtype,objlang,objid)
    )');
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD tempcol VARCHAR(50)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=VARCHAR_FORMAT(wisheddate,"YYYYMMDD")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP wisheddate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD wisheddate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=VARCHAR_FORMAT(firstpostdate,"YYYYMMDD HH24MISS")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP firstpostdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD firstpostdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=VARCHAR_FORMAT(lastpostdate,"YYYYMMDD HH24MISS")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP lastpostdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD lastpostdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=tempcol' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP tempcol' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD tempcol VARCHAR(50)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET tempcol=VARCHAR_FORMAT(issuedate,"YYYYMMDD HH24MISS")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP issuedate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD issuedate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET tempcol=VARCHAR_FORMAT(modifdate,"YYYYMMDD HH24MISS")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP modifdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD modifdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=tempcol' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP tempcol' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD tempcol VARCHAR(50)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET tempcol=VARCHAR_FORMAT(firstdate,"YYYYMMDD HH24MISS")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP firstdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD firstdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET tempcol=VARCHAR_FORMAT(lastdate,"YYYYMMDD HH24MISS")' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP lastdate' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD lastdate VARCHAR(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=tempcol' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP tempcol' );
    break;

  case 'ifx':
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype varchar(10),
    objlang varchar(2),
    objid varchar(24),
    objname varchar(4000),
    PRIMARY KEY (objtype,objlang,objid)
    )');
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD (tempcol VARCHAR(50))' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=TO_CHAR(wisheddate,"%Y%m%d")' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP (wisheddate)' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD (wisheddate VARCHAR(20))' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=TO_CHAR(firstpostdate,"%Y%m%d %H%M")' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP (firstpostdate)' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD (firstpostdate VARCHAR(20))' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET tempcol=TO_CHAR(lastpostdate,"%Y%m%d %H%M")' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP (lastpostdate)' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic ADD (lastpostdate VARCHAR(20))' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=tempcol' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic DROP (tempcol)' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD (tempcol VARCHAR(50))' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET tempcol=TO_CHAR(issuedate,"%Y%m%d %H%M")' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP (issuedate)' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD (issuedate VARCHAR(20))' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET tempcol=TO_CHAR(modifdate,"%Y%m%d %H%M")' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP (modifdate)' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD (modifdate VARCHAR(20))' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=tempcol' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP (tempcol)' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD (tempcol VARCHAR(50))' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET tempcol=TO_CHAR(firstdate,"%Y%m%d %H%M")' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP (firstdate)' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD (firstdate VARCHAR(20))' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=tempcol' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET tempcol=TO_CHAR(lastdate,"%Y%m%d %H%M")' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP (lastdate)' );
      $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser ADD (lastdate VARCHAR(20))' );
      $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=tempcol' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser DROP (tempcol)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET birthday=REPLACE(birthday,"-",""), firstdate=REPLACE(firstdate,"-",""), lastdate=REPLACE(lastdate,"-","")' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=REPLACE(firstdate,":",""), lastdate=REPLACE(lastdate,":","")' );
    break;

  case 'oci':
    $oDB->Query( 'CREATE TABLE '.$qti_prefix.'qtilang (
    objtype varchar2(10),
    objlang varchar2(2),
    objid varchar2(24),
    objname varchar2(4000),
    CONSTRAINT pk_'.$qti_prefix.'qtilang PRIMARY KEY (objtype,objlang,objid))');
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic MODIFY wisheddate VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET wisheddate="0" WHERE wisheddate IS NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic MODIFY firstpostdate VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate="0" WHERE firstpostdate IS NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtitopic MODIFY lastpostdate VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate="0" WHERE lastpostdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET firstpostdate=SUBSTR(firstpostdate,1,8) || " " || SUBSTR(firstpostdate,-6,6) WHERE firstpostdate<>"0"');
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtitopic SET lastpostdate=SUBSTR(lastpostdate,1,8) || " " || SUBSTR(lastpostdate,-6,6) WHERE lastpostdate<>"0"');

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost MODIFY issuedate VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate="0" WHERE issuedate IS NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost MODIFY modifdate VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate="0" WHERE modifdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET issuedate=SUBSTR(issuedate,1,8) || " " || SUBSTR(issuedate,-6,6) WHERE issuedate<>"0"');
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET modifdate=SUBSTR(modifdate,1,8) || " " || SUBSTR(modifdate,-6,6) WHERE modifdate<>"0"');
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost ADD textmsg2 VARCHAR2(4000)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtipost SET textmsg2=SUBSTR(textmsg,1,4000)' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost DROP textmsg2' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtipost RENAME COLUMN textmsg2 to textmsg' );

    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser MODIFY birthday VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET birthday="0" WHERE birthday IS NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser MODIFY firstdate VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate="0" WHERE firstdate IS NULL' );
    $oDB->Query( 'ALTER TABLE '.$qti_prefix.'qtiuser MODIFY lastdate VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate="0" WHERE lastdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET firstdate=SUBSTR(firstdate,1,8) || " " || SUBSTR(firstdate,-6,6) WHERE firstdate<>"0"');
    $oDB->Query( 'UPDATE '.$qti_prefix.'qtiuser SET lastdate=SUBSTR(lastdate,1,8) || " " || SUBSTR(lastdate,-6,6) WHERE lastdate<>"0"');
    break;

  default:
    die("Database type [{$oDB->type}] not supported... Must be mysql, mssql, pg, sqlite, firebird, db2, ifx or access");

  }

    // transfers section descriptions

    $oDB2 = new cDB($qti_dbsystem,$qti_host,$qti_database,$qti_user,$qti_pwd,$qti_port,$qti_dsn);
    $oDB2->Query( 'SELECT id,description FROM '.$qti_prefix.'qtiforum ' );
    $arr = array();
    while($row=$oDB2->Getrow())
    {
      $arr[$row['id']] = $row['description'];
    }
    foreach ($arr as $id=>$str)
    {
    $oDB2->Query( 'DELETE FROM '.$qti_prefix.'qtilang WHERE objtype="secdesc" AND objid="'.$id.'"' );
    $oDB2->Query( 'INSERT INTO '.$qti_prefix.'qtilang (objtype,objlang,objid,objname) VALUES ("secdesc","en","s'.$id.'","'.addslashes($str).'")' );
    }

  // register version

  $oDB->Query('UPDATE '.$qti_prefix.'qtisetting SET setting="1.9" WHERE param="version"');
  if ( isset($qti_install) ) { define('QT','qti'.substr($qti_install,-1)); } else { define('QT','qti'); }
  $_SESSION[QT]['version']='1.9';
  $strMessage .= '<p>Database upgraded to 1.9</p>';

}

// --------
// HTML START
// --------

include('qti_setup_hd.php');

if (!empty($strMessage) ) echo $strMessage;

if ( isset($_SESSION['qtiInstalled']) )
{
echo '<p>Database 1.9 in place.</p>';
echo '<p>',$L['S_install_exit'],'</p>';
echo '<div style="width:350px; padding:10px; border-style:solid; border-color:#FF0000; border-width:1px; background-color:#EEEEEE">',$L['End_message'],'<br/>',$L['User'],': <b>Admin</b><br/>',$L['Password'],': <b>Admin</b><br/></div><br/>';
}
else
{
echo $L['N_install'];
}

echo '<p><a href="../check_install.php">',$L['Check_install'],'</a></p>';

// --------
// HTML END
// --------

include('qti_setup_ft.php');

// --------
// SESSION DESTROY
// --------

$_SESSION=array();
session_destroy();
if ( isset($qti_install) ) { define('QT','qti'.substr($qti_install,-1)); } else { define('QT','qti'); }
if ( isset($_COOKIE[QT.'_cookname']) ) setcookie(QT.'_cookname', '', time()+60*60*24*100, '/');
if ( isset($_COOKIE[QT.'_cookpass']) ) setcookie(QT.'_cookpass', '', time()+60*60*24*100, '/');

?>
Return current item: QuickTicket