Location: PHPKode > projects > QuickTalk Forum > quicktalk/install/qtf_setup_3.php
<?php

// QuickTalk 2.5 build:20100924

session_start();

if ( !isset($_SESSION['qtf_setup_lang']) ) $_SESSION['qtf_setup_lang']='en';
$strLang=$_SESSION['qtf_setup_lang']; // remember in ordrer to restore after reset (end of page)

include('qtf_lang_'.$strLang.'.php');
include('../bin/config.php'); if ( $qtf_dbsystem=='sqlite' ) $qtf_database = '../'.$qtf_database;
include('../bin/qt_lib_db.php');

$strAppl     = 'QuickTalk 2.5';
$strPrevUrl  = 'qtf_setup_2.php';
$strNextUrl  = '../qtf_login.php?dfltname=Admin';
$strPrevLabel= $L['Back'];
$strNextLabel= $L['Finish'];
$strMessage = '';

// CHECK DB VERSION (in case of update)

$oDB = new cDB($qtf_dbsystem,$qtf_host,$qtf_database,$qtf_user,$qtf_pwd,$qtf_port,$qtf_dsn);
if ( !empty($oDB->error) ) die ('<p><font color="red">Connection with database failed.<br/>Please contact the webmaster for further information.</font></p><p>The webmaster must check that server is up and running, and that the settings in the config file are correct for the database.</p>');

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

// UPDAGRADE TO 1.8 (nothing to do)

if ( $row['setting']=='1.7' ) 
{
  $row['setting']='1.8';
  $strMessage .= '<p>Database upgraded to 1.8</p>';
}

// UPDAGRADE TO 1.9

if ( $row['setting']=='1.8' )
{
  $oDB->Query( 'INSERT INTO '.$qtf_prefix.'qtasetting VALUES ("login_qte_web","0","1")' );
  $oDB->Query( 'INSERT INTO '.$qtf_prefix.'qtasetting VALUES ("login_qte","0","1")' );
  $oDB->Query( 'UPDATE '.$qtf_prefix.'qtasetting SET param="index_name" WHERE param="forum_index_name"' );
  $oDB->Query( 'UPDATE '.$qtf_prefix.'qtasetting SET param="section_desc" WHERE param="forum_descr"' );
  $oDB->Query( 'UPDATE '.$qtf_prefix.'qtasetting SET param="sys_welcome" WHERE param="forum_welcome"' );
  if ( $oDB->type=='oci' ) $oDB->Query( 'UPDATE '.$qtf_prefix.'qtasetting SET setting="4000" WHERE param="chars_per_post"' );

  switch($oDB->type)
  {

  case 'mysql4':

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

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

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

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

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

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

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

    // qtatopic

    $oDB->Query( 'CREATE TABLE '.$qtf_prefix.'qtatopic2 (
    id int NULL,
    numid int NULL,
    forum int NULL,
    type char(1) NULL,
    status char(1) NULL,
    firstpostid int NULL,
    lastpostid int NULL,
    firstpostuser int NULL,
    lastpostuser int NULL,
    firstpostname NULL,
    lastpostname NULL,
    firstpostdate NULL,
    lastpostdate NULL,
    replies int NULL,
    views int NULL,
    PRIMARY KEY (id)
    )' );
    $oDB->Query( 'INSERT INTO '.$qtf_prefix.'qtatopic2 SELECT id,numid,forum,type,status,firstpostid,lastpostid,firstpostuser,lastpostuser,firstpostname,lastpostname,CONVERT(VARCHAR,firstpostdate,120),CONVERT(VARCHAR,lastpostdate,120),replies,views FROM '.$qtf_prefix.'qtatopic' );
    $oDB->Query( 'DROP TABLE '.$qtf_prefix.'qtatopic' );
    $oDB->Query( 'CREATE TABLE '.$qtf_prefix.'qtatopic (
    id int,
    numid int default 0,
    forum int default 0,
    type char(1) default "T",
    status char(1) default "0",
    firstpostid int default 0,
    lastpostid int default 0,
    firstpostuser int default 0,
    lastpostuser int default 0,
    firstpostname varchar(24),
    lastpostname varchar(24),
    firstpostdate varchar(20),
    lastpostdate varchar(20),
    replies int default 0,
    views int default 0,
    PRIMARY KEY (id)
      )' );
    $oDB->Query( 'INSERT INTO '.$qtf_prefix.'qtatopic SELECT * FROM '.$qtf_prefix.'qtatopic2' );
    $oDB->Query( 'DROP TABLE '.$qtf_prefix.'qtatopic2' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic SET firstpostdate=REPLACE(firstpostdate,"-","") WHERE firstpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic SET firstpostdate=REPLACE(firstpostdate,":","") WHERE firstpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic SET lastpostdate=REPLACE(lastpostdate,"-","") WHERE lastpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic SET lastpostdate=REPLACE(lastpostdate,":","") WHERE lastpostdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic SET firstpostdate="0" WHERE firstpostdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic SET lastpostdate="0" WHERE lastpostdate IS NULL' );

    // qtapost

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

    // qtauser

    $oDB->Query( 'CREATE TABLE '.$qtf_prefix.'qtauser2 (
      id int NOT NULL CONSTRAINT pk_'.$qtf_prefix.'qtauser2 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 '.$qtf_prefix.'qtauser2 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 '.$qtf_prefix.'qtauser' );
    $oDB->Query( 'DROP TABLE '.$qtf_prefix.'qtauser' );
    $oDB->Query( 'CREATE TABLE '.$qtf_prefix.'qtauser (
    id int NOT NULL CONSTRAINT pk_'.$qtf_prefix.'qtauser PRIMARY KEY,
    name varchar(24) NOT NULL CONSTRAINT uk_'.$qtf_prefix.'qtauser 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 '.$qtf_prefix.'qtauser SELECT * FROM '.$qtf_prefix.'qtauser2' );
    $oDB->Query( 'DROP TABLE '.$qtf_prefix.'qtauser2' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET firstdate=REPLACE(firstdate,"-","") WHERE firstdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET firstdate=REPLACE(firstdate,":","") WHERE firstdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET lastdate=REPLACE(lastdate,"-","") WHERE lastdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET lastdate=REPLACE(lastdate,":","") WHERE lastdate IS NOT NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET birthday="0" WHERE birthday IS NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET firstdate="0" WHERE firstdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET lastdate="0" WHERE lastdate IS NULL' );

    break;

  case 'pg':

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

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

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

    break;

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

  case 'ibase':
    $oDB->Query( 'CREATE TABLE '.$qtf_prefix.'qtalang (
    objtype varchar(10),
    objlang varchar(2),
    objid varchar(24),
    objname varchar(4000),
    PRIMARY KEY (objtype,objlang,objid)
    )' );
    $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtatopic ADD tempcol VARCHAR(50) DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic 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 '.$qtf_prefix.'qtatopic DROP firstpostdate' );
      $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtatopic ADD firstpostdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic SET firstpostdate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
      $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic SET tempcol="0"' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic 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 '.$qtf_prefix.'qtatopic DROP lastpostdate' );
      $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtatopic ADD lastpostdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qtf_prefix.'qtatopic SET lastpostdate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtatopic DROP tempcol' );

    $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtapost ADD tempcol VARCHAR(50) DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtapost 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 '.$qtf_prefix.'qtapost DROP issuedate' );
      $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtapost ADD issuedate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qtf_prefix.'qtapost SET issuedate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
      $oDB->Query( 'UPDATE '.$qtf_prefix.'qtapost SET tempcol="0"' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtapost 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 '.$qtf_prefix.'qtapost DROP modifdate' );
      $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtapost ADD modifdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qtf_prefix.'qtapost SET modifdate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtapost DROP tempcol' );

    $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtauser ADD tempcol VARCHAR(50) DEFAULT "0"' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser 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 '.$qtf_prefix.'qtauser DROP firstdate' );
      $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtauser ADD firstdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET firstdate=SUBSTRING(tempcol FROM 1 FOR 15)' );
      $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET tempcol="0"' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser 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 '.$qtf_prefix.'qtauser DROP lastdate' );
      $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtauser ADD lastdate VARCHAR(20) DEFAULT "0"' );
      $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET lastdate=SUBSTRING(tempcol FROM 1 FOR 15) WHERE tempcol<>"0"' );
    $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtauser DROP tempcol' );
    break;

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

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

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

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

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

    $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtauser MODIFY birthday VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET birthday="0" WHERE birthday IS NULL' );
    $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtauser MODIFY firstdate VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET firstdate="0" WHERE firstdate IS NULL' );
    $oDB->Query( 'ALTER TABLE '.$qtf_prefix.'qtauser MODIFY lastdate VARCHAR2(20)' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET lastdate="0" WHERE lastdate IS NULL' );
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET firstdate=SUBSTR(firstdate,1,8) || " " || SUBSTR(firstdate,-6,6) WHERE firstdate<>"0"');
    $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser 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, oci");

  }

    // transfers section descriptions

    $oDB2 = new cDB($qtf_dbsystem,$qtf_host,$qtf_database,$qtf_user,$qtf_pwd,$qtf_port,$qtf_dsn);
    $oDB2->Query( 'SELECT id,description FROM '.$qtf_prefix.'qtaforum ' );
    $arr = array();
    while($row=$oDB2->Getrow())
    {
      $arr[$row['id']] = $row['description'];
    }
    foreach($arr as $id=>$str)
    {
    $oDB2->Query( 'DELETE FROM '.$qtf_prefix.'qtalang WHERE objtype="secdesc" AND objid="'.$id.'"' );
    $oDB2->Query( 'INSERT INTO '.$qtf_prefix.'qtalang (objtype,objlang,objid,objname) VALUES ("secdesc","en","s'.$id.'","'.addslashes($str).'")' );
    }

  // register version

  $oDB->Query('UPDATE '.$qtf_prefix.'qtasetting SET setting="1.9" WHERE param="version"');
  $row['setting']='1.9';
  $strMessage .= '<p>Database upgraded to 1.9</p>';

}

// UPDAGRADE TO 2.0

if ( $row['setting']=='1.9' )
{
  $oDB->Query('INSERT INTO '.$qtf_prefix.'qtasetting VALUES ("tags", "M", "1")');

  switch (substr($oDB->type,0,5))
  {
  case 'mysql':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD picture varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD notify char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD stats varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD sortfield varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD prefix char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD logo varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD statusdate varchar(20)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD tags varchar('.($oDB->type==mysql4 ? '255' : '4000').')');
    break;
  case 'mssql':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD picture varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD notify char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD stats varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD sortfield varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD prefix char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD logo varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD statusdate varchar(20)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD tags varchar(4000)');
    break;
  case 'pg':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD picture varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD notify char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD stats varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD sortfield varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD prefix char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD logo varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD statusdate varchar(20)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD tags varchar(4000)');
    break;
  case 'ibase':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD picture varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD notify char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD stats varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD sortfield varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD prefix char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD logo varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD statusdate varchar(20)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD tags varchar(4000)');
    break;
  case 'sqlit':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD picture text');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD notify text');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD stats text');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD sortfield text');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD prefix text');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD logo text');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD statusdate text');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD tags text');
    break;
  case 'db2':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD picture varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD notify char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD stats varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD sortfield varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD prefix char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD logo varchar(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD statusdate varchar(20)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD tags varchar(4000)');
    break;
  case 'oci':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD picture varchar2(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD notify char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD stats varchar2(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD sortfield varchar2(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD prefix char(1)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD logo varchar2(24)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD statusdate varchar2(20)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD tags varchar2(4000)');
    break;
  }
  $oDB->Query('UPDATE '.$qtf_prefix.'qtaforum SET prefix="a"');

  // update section stats
  
  $oDB->Query('SELECT id,topics,replies FROM '.$qtf_prefix.'qtaforum');
  $arrList = array();
  while($row = $oDB->Getrow()) { $arrList[]=$row; }
  foreach($arrList as $arr) { $oDB->Query( 'UPDATE '.$qtf_prefix.'qtaforum SET stats="topics='.(empty($arr['topics']) ? '0' : $arr['topics']).';replies='.(empty($arr['replies']) ? '0' : $arr['replies']).';tags=0" WHERE id='.$arr['id'] ); }

  // Update picture from avatar
  
  $oDB->Query('SELECT id,avatar FROM '.$qtf_prefix.'qtauser');
  $arr = array();
  while($row=$oDB->Getrow())
  {
    if ( !empty($row['avatar']) ) $arr[$row['id']]=$row['avatar'];
  }
  foreach($arr as $strKey=>$strValue)
  {
  $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET picture="'.$strKey.'.'.$strValue.'" WHERE id='.$strKey );
  }

  // Register version

  $oDB->Query('UPDATE '.$qtf_prefix.'qtasetting SET setting="2.0" WHERE param="version"');
  $row['setting']='2.0';
  $strMessage .= '<p>Database upgraded to 2.0</p>';

}

// UPDAGRADE TO 2.1

if ( $row['setting']=='2.0' ) 
{
  switch($oDB->type)
  {
  case 'sqlite':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD modifdate text');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD options text');
    break;
  case 'oci':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD modifdate varchar2(20)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD options varchar2(255)');
    break;
  default:
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD modifdate varchar(20)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtaforum ADD options varchar(255)');
    break;
  }  
  // update section options

  $oDB->Query('SELECT id,sortfield,infofield,logo FROM '.$qtf_prefix.'qtaforum');
  $arr = array();
  while($row=$oDB->Getrow())
  {
    if ( $row['sortfield']=='lastpostdate' ) $row['sortfield']='0';
    if ( $row['infofield']=='N' ) $row['infofield']='0';
    $arr[$row['id']]='coord=0;order='.(empty($row['sortfield']) ? '0' : $row['sortfield']).';last='.(empty($row['infofield']) ? '0' : $row['infofield']).';logo='.(empty($row['logo']) ? '0' : $row['logo']);
  }
  foreach($arr as $strKey=>$strValue)
  {
  $oDB->Query( 'UPDATE '.$qtf_prefix.'qtaforum SET options="'.$strValue.'" WHERE id='.$strKey );
  }

  // Update picture dir
  
  $oDB->Query('SELECT id,picture FROM '.$qtf_prefix.'qtauser');
  $arr = array();
  while($row=$oDB->Getrow())
  {
    if ( !empty($row['picture']) ) {
    if ( strtolower(substr($row['picture'],0,7))=='avatar/' ) {
      $arr[$row['id']]=substr($row['picture'],7);
    }}
  }
  foreach($arr as $strKey=>$strValue)
  {
  $oDB->Query( 'UPDATE '.$qtf_prefix.'qtauser SET picture="'.$strValue.'" WHERE id='.$strKey );
  }

  // Register version

  $oDB->Query('UPDATE '.$qtf_prefix.'qtasetting SET setting="2.1" WHERE param="version"');
  $row['setting']='2.1';
  $strMessage .= '<p>Database upgraded to 2.1</p>';
}

// UPDAGRADE 2.1 TO 2.4

if ( $row['setting']=='2.1' || $row['setting']=='2.2' || $row['setting']=='2.3' )
{
  $oDB->Query('UPDATE '.$qtf_prefix.'qtasetting SET setting="2.4" WHERE param="version"');
  switch($oDB->type)
  {
  case 'sqlite':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD param text');
    break;
  case 'oci':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD param varchar2(255)');
    break;
  default:
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtatopic ADD param varchar(255)');
    break;
  }  
  $row['setting']='2.4';
  $strMessage .= '<p>Database upgraded to 2.4</p>';
}

// UPDAGRADE 2.4 TO 2.5

if ( $row['setting']=='2.4' )
{
  $oDB->Query('UPDATE '.$qtf_prefix.'qtasetting SET setting="2.5" WHERE param="version"');
  switch($oDB->type)
  {
  case 'sqlite':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD secret_q text');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD secret_a text');
    break;
  case 'oci':
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD secret_q varchar2(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD secret_a varchar2(255)');
    break;
  default:
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD secret_q varchar(255)');
    $oDB->Query('ALTER TABLE '.$qtf_prefix.'qtauser ADD secret_a varchar(255)');
    break;
  }  
  $row['setting']='2.5';
  $strMessage .= '<p>Database upgraded to 2.5</p>';
}

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

include('qtf_setup_hd.php');

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

if ( isset($_SESSION['qtfInstalled']) )
{
echo '<p>Database 2.5 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'];
}

// document folders

$error='';
if ( !is_dir('upload') )
{
  $error .= '<font color=red>Directory <b>upload</b> not found.</font><br/>Please create this directory and make it writeable (chmod 777) if you want to allow uploads<br/>';
}
else
{
  if ( !is_readable('upload') ) $error .= '<font color=red>Directory <b>upload</b> is not readable.</font><br/>Change permissions (chmod 777) if you want to allow uploads<br/>';
  if ( !is_writable('upload') ) $error .= '<font color=red>Directory <b>upload</b> is not writable.</font><br/>Change permissions (chmod 777) if you want to allow uploads<br/>';
}

if ( empty($error) )
{
  $iY = intval(date('Y'));
  for ($i=$iY;$i<=$iY+5;$i++)
  {
    if ( !is_dir('upload/'.$i) )
    {
      if ( mkdir('upload/'.$i) )
      {
        for ($j=1;$j<=12;$j++)
        {
        mkdir('upload/'.$i.'/'.($i*100+$j));
        }
      }
    }
  }
}

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

// DISCONNECT to reload new variables

$_SESSION = array();
$_SESSION['qtf_setup_lang']=$strLang; // restore language after reset

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

include('qtf_setup_ft.php');

?>
Return current item: QuickTalk Forum