fehler beim update von 1.5.7 auf 1.6.3: invalid databasetype

Please report bugs here!

Moderator: Thorsten

Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

die Queries für die 1.5.x brauchst du auch noch.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
carhartt
Posts: 105
Joined: Mon Sep 08, 2003 12:46 pm

Post by carhartt »

also dann so?

Code: Select all

<?php
<html>
<body>

if ($step == 5) {
    require_once(PMF_ROOT_DIR."/inc/functions.php");
    require_once(PMF_ROOT_DIR."/inc/db.php");
    define("SQLPREFIX", $DB["prefix"]);
    $db = db::db_select($DB["type"]);
    $db->connect($DB["server"], $DB["user"], $DB["password"], $DB["db"]);

    $version = str_replace(".", "", $_REQUEST["version"]);
    if (4 == strlen($version)) {
        $version = 149;
    }


    // update from version 1.4.0
    if ($version <= "140") {
        // rewrite data.php
        if ($fp = @fopen("../inc/data.php","w")) {
    		@fputs($fp,"<?php\n\$DB[\"server\"] = '".$DB["server"]."';\n\$DB[\"user\"] = '".$DB["user"]."';\n\$DB[\"password\"] = '".$DB["password"]."';\n\$DB[\"db\"] = '".$DB["db"]."';\n\$DB[\"prefix\"] = '".SQLPREFIX."';\n\$DB[\"type\"] = 'mysql';\n?>");
    		@fclose($fp);
        } else {
    		print "<p class=\"error\"><strong>Error:</strong> Cannot rewrite to data.php.</p>";
        }
    }
    // update from version 1.4.2
    if ($version < "142") {
        $query[] = "ALTER TABLE ".SQLPREFIX."faqadminlog CHANGE user usr INT(11) DEFAULT '0' NOT NULL";
        $query[] = "ALTER TABLE ".SQLPREFIX."faqadminsessions CHANGE user usr TINYTEXT NOT NULL";
        $query[] = "ALTER TABLE ".SQLPREFIX."faqchanges CHANGE user usr INT(11) DEFAULT '0' NOT NULL";
        $query[] = "ALTER TABLE ".SQLPREFIX."faqcomments CHANGE user usr VARCHAR(255) NOT NULL";
        $query[] = "ALTER TABLE ".SQLPREFIX."faqvoting CHANGE user usr INT(11) DEFAULT '0' NOT NULL";
    }
    // update from version 1.4.4
    if ($version <= "144") {
        $query[] = "ALTER TABLE ".SQLPREFIX."faqdata CHANGE content content LONGTEXT NOT NULL";

 // update from versions before 1.5.2
    if ($version < 152) {
        switch($DB["type"]) {
            case 'mssql':   $query[] = 'CREATE INDEX idx_record_id_lang ON '.SQLPREFIX.'faqcategoryrelations (record_id, record_lang)';
                            break;
            default:        $query[] = 'ALTER TABLE '.SQLPREFIX.'faqcategoryrelations ADD INDEX idx_record_id_lang (record_id, record_lang)';
                            break;
        }
    }
    // update from versions before 1.5.5
    if ($version < 155) {
        // Fix unuseful slashes
        // Table: faqcategories
        $faqCategoriesQuery = "SELECT * FROM ".SQLPREFIX."faqcategories"
                             ." WHERE     name LIKE '%\\\\\\\\%'"
                             ." OR description LIKE '%\\\\\\\\%'";
        $faqCategories = $db->query($faqCategoriesQuery);
        if ($db->num_rows($faqCategories) > 0) {
            while ($row = $db->fetch_object($faqCategories)) {
                switch($DB["type"]) {
                    default:
                        $query[] = "UPDATE ".SQLPREFIX."faqcategories SET "
                                 ."         name = '".$db->escape_string(fixslashes($row->name))."'"
                                 .", description = '".$db->escape_string(fixslashes($row->description))."'"
                                 ." WHERE id = '".$row->id."'";
                        break;
                }
            }
        }
        // Table: faqdata
        $faqDataQuery = "SELECT * FROM ".SQLPREFIX."faqdata"
                       ." WHERE thema LIKE '%\\\\\\\\%'"
                       ." OR  content LIKE '%\\\\\\\\%'"
                       ." OR keywords LIKE '%\\\\\\\\%'"
                       ." OR   author LIKE '%\\\\\\\\%'";
        $faqData = $db->query($faqDataQuery);
        if ($db->num_rows($faqData) > 0) {
            while ($row = $db->fetch_object($faqData)) {
                switch($DB["type"]) {
                    default:
                        $query[] = "UPDATE ".SQLPREFIX."faqdata SET "
                                 ."     thema = '".$db->escape_string(fixslashes($row->thema))."'"
                                 .",  content = '".$db->escape_string(fixslashes($row->content))."'"
                                 .", keywords = '".$db->escape_string(fixslashes($row->keywords))."'"
                                 .",   author = '".$db->escape_string(fixslashes($row->author))."'"
                                 ." WHERE id = '".$row->id."'";
                        break;
                }
            }
        }
        // Table: faqcomments
        $faqCommentsQuery = "SELECT * FROM ".SQLPREFIX."faqcomments"
                           ." WHERE  usr LIKE '%\\\\\\\\%'"
                           ." OR comment LIKE '%\\\\\\\\%'";
        $faqComments = $db->query($faqCommentsQuery);
        if ($db->num_rows($faqComments) > 0) {
            while ($row = $db->fetch_object($faqComments)) {
                switch($DB["type"]) {
                    default:
                        $query[] = "UPDATE ".SQLPREFIX."faqcomments SET "
                                 ."      usr = '".$db->escape_string(fixslashes($row->usr))."'"
                                 .", comment = '".$db->escape_string(fixslashes($row->comment))."'"
                                 ." WHERE id_comment = '".$row->id_comment."'";
                        break;
                }
            }
        }
        // Table: faqfragen
        $faqQuestionsQuery = "SELECT * FROM ".SQLPREFIX."faqfragen"
                            ." WHERE ask_username LIKE '%\\\\\\\\%'"
                            ."     OR ask_content LIKE '%\\\\\\\\%'";
        $faqQuestions = $db->query($faqQuestionsQuery);
        if ($db->num_rows($faqQuestions) > 0) {
            while ($row = $db->fetch_object($faqQuestions)) {
                switch($DB["type"]) {
                    default:
                        $query[] = "UPDATE ".SQLPREFIX."faqfragen SET "
                                 ." ask_username = '".$db->escape_string(fixslashes($row->ask_username))."'"
                                 .", ask_content = '".$db->escape_string(fixslashes($row->ask_content))."'"
                                 ." WHERE id = '".$row->id."'";
                        break;
                }
            }
        }
    }

    // update from versions before 1.6.0
    if ($version < 160) {
        // add revision_id and solution_id
        // 1/2. Fix faqdata and faqchanges tables
        switch($DB["type"]) {
            case 'pgsql':
                // faqdata (NEW) from install/pgsql.sql.php
                $query[] = "CREATE TABLE ".SQLPREFIX."faqdata_new (
                            id SERIAL NOT NULL,
                            lang varchar(5) NOT NULL,
                            solution_id bigint NOT NULL,
                            revision_id bigint NOT NULL DEFAULT 0,
                            active char(3) NOT NULL,
                            keywords text NOT NULL,
                            thema text NOT NULL,
                            content text NOT NULL,
                            author varchar(255) NOT NULL,
                            email varchar(255) NOT NULL,
                            comment char(1) NOT NULL default 'y',
                            datum varchar(15) NOT NULL,
                            PRIMARY KEY (id, lang))";
                // Copy data from the (old) faqdata
                $query[] = 'INSERT INTO '.SQLPREFIX.'faqdata_new
                            (id, lang, active, keywords, thema, content, author, email, comment, datum)
                            SELECT id, lang, active, keywords, thema, content, author, email, comment, datum
                            FROM '.SQLPREFIX.'faqdata';
                // Drop the (old) faqdata and rename the new faqdata table
                $query[] = 'ALTER TABLE '.SQLPREFIX.'faqdata     RENAME TO '.SQLPREFIX.'faqdata_PMF155_old';
                $query[] = 'ALTER TABLE '.SQLPREFIX.'faqdata_new RENAME TO '.SQLPREFIX.'faqdata';
                // TODO: uncoment the DROP TABLE command below after testing on PostgreSQL
                //$query[] = 'DROP TABLE '.SQLPREFIX.'faqdata_PMF155_old';
                // faqchanges (NEW) from install/pgsql.sql.php
                $query[] = "CREATE TABLE ".SQLPREFIX."faqchanges_new (
                            id SERIAL NOT NULL,
                            beitrag bigint NOT NULL,
                            lang varchar(5) NOT NULL,
                            revision_id integer NOT NULL DEFAULT 0,
                            usr bigint NOT NULL REFERENCES ".SQLPREFIX."faquser(id),
                            datum bigint NOT NULL,
                            what text NOT NULL,
                            PRIMARY KEY (id, lang))";
                // Copy data from the (old) faqchanges
                $query[] = 'INSERT INTO '.SQLPREFIX.'faqchanges_new
                            (id, beitrag, lang, usr, datum, what)
                            SELECT id, beitrag, lang, usr, datum, what
                            FROM '.SQLPREFIX.'faqchanges';
                // Drop the (old) faqchanges and rename the new faqchanges table
                $query[] = 'ALTER TABLE '.SQLPREFIX.'faqchanges     RENAME TO '.SQLPREFIX.'faqchanges_PMF155_old';
                $query[] = 'ALTER TABLE '.SQLPREFIX.'faqchanges_new RENAME TO '.SQLPREFIX.'faqchanges';
                // TODO: uncoment the DROP TABLE command below after testing on PostgreSQL
                //$query[] = 'DROP TABLE '.SQLPREFIX.'faqchanges_PMF155_old';
                break;
            default:
                $query[] = 'ALTER TABLE '.SQLPREFIX.'faqdata ADD solution_id INTEGER NOT NULL AFTER lang';
                $query[] = 'ALTER TABLE '.SQLPREFIX.'faqdata ADD revision_id INTEGER NOT NULL AFTER solution_id';
                $query[] = 'ALTER TABLE '.SQLPREFIX.'faqchanges ADD revision_id INTEGER NOT NULL AFTER lang';
                break;
        }
        // 2/2. Add faqdata_revisions table
        switch($DB["type"]) {
            case 'mysql':
            case 'mysqli':
            case 'sqlite':
                $query[] = "CREATE TABLE ".SQLPREFIX."faqdata_revisions (id int(11) NOT NULL, lang varchar(5) NOT NULL, solution_id int(11) NOT NULL, revision_id int(11) NOT NULL DEFAULT 0, active char(3) NOT NULL, keywords text NOT NULL, thema text NOT NULL, content longtext NOT NULL, author varchar(255) NOT NULL, email varchar(255) NOT NULL, comment char(1) NOT NULL, datum varchar(15) NOT NULL, PRIMARY KEY (id, lang, solution_id, revision_id))";
                break;
            case 'db2':
                $query[] = "CREATE TABLE ".SQLPREFIX."faqdata_revisions (id integer NOT NULL, lang varchar(5) NOT NULL, solution_id integer NOT NULL, revision_id integer NOT NULL DEFAULT 0, active char(3) NOT NULL, keywords varchar(512) NOT NULL, thema varchar(512) NOT NULL, content CLOB NOT NULL, author varchar(255) NOT NULL, email varchar(255) NOT NULL, comment char(1) default 'y', datum varchar(15) NOT NULL, PRIMARY KEY (id, lang, solution_id, revision_id))";
                break;
            default:
                $query[] = "CREATE TABLE ".SQLPREFIX."faqdata_revisions (id integer NOT NULL, lang varchar(5) NOT NULL, solution_id integer NOT NULL, revision_id integer NOT NULL DEFAULT 0, active char(3) NOT NULL, keywords varchar(512) NOT NULL, thema varchar(512) NOT NULL, content TEXT NOT NULL, author varchar(255) NOT NULL, email varchar(255) NOT NULL, comment char(1) default 'y', datum varchar(15) NOT NULL, PRIMARY KEY (id, lang, solution_id, revision_id))";
                break;
        }

        // add the new "edit revisions" right to the existing user rights profiles
        // 1/2. Fix admin/id=1 user rights
        $query[] = "UPDATE ".SQLPREFIX."faquser SET rights = '11111111111111111111111' WHERE id = 1";
        // 2/2. Fix normal user rights
        $_records = array();
        $_result = $db->query('SELECT id, rights FROM '.SQLPREFIX.'faquser WHERE id <> 1 ORDER BY id');
        while ($row = $db->fetch_object($_result)) {
            $_records[] = array('id' => $row->id, 'rights' => $row->rights);
        }
        foreach ($_records as $_r) {
            $query[] = "UPDATE ".SQLPREFIX."faquser SET rights = '".$_r['rights']."0' WHERE id = ".$_r['id'];
        }
        // add captcha support
        $query[] = 'CREATE TABLE '.SQLPREFIX.'faqcaptcha ( id varchar(6) NOT NULL, useragent varchar(255) NOT NULL, language varchar(2) NOT NULL, ip varchar(64) NOT NULL, captcha_time integer NOT NULL, PRIMARY KEY (id))';
        // add solution id to existing records
        $_records = array();
        $_result = $db->query('SELECT id, lang FROM '.SQLPREFIX.'faqdata ORDER BY id, lang');
        while ($row = $db->fetch_object($_result)) {
            $_records[] = array('id' => $row->id, 'lang' => $row->lang);
        }
        $_start = PMF_SOLUTION_ID_START_VALUE;
        foreach ($_records as $_r) {
            $query[] = "UPDATE ".SQLPREFIX."faqdata SET solution_id = ".$_start." WHERE id = ".$_r['id']." AND lang = '".$_r['lang']."'";
            $_start += PMF_SOLUTION_ID_INCREMENT_VALUE;
        }
    }

    // optimize tables
    switch($DB["type"]) {
        case 'mysql':
        case 'mysqli':      $query[] = "OPTIMIZE TABLE ".SQLPREFIX."faqadminlog, ".SQLPREFIX."faqadminsessions, ".SQLPREFIX."faqcategories, ".SQLPREFIX."faqcategoryrelations, ".SQLPREFIX."faqchanges, ".SQLPREFIX."faqcomments, ".SQLPREFIX."faqdata, ".SQLPREFIX."faqfragen, ".SQLPREFIX."faqnews, ".SQLPREFIX."faqsessions, ".SQLPREFIX."faquser, ".SQLPREFIX."faqvisits, ".SQLPREFIX."faqvoting";
                            break;
        case 'pgsql':       $query[] = "VACUUM ANALYZE;";
                            break;
    }

    print '<p class="center">';
    if (isset($query)) {
        while ($each_query = each($query)) {
            $result = $db->query($each_query[1]);
            print "|&nbsp;\n";
            if (!$result) {
                print "<p class=\"error\"><strong>Error:</strong> ".$db->error()."</p>\n";
                print "<p>Query:</p>\n";
                print "<pre>".PMF_htmlentities($each_query[1])."</pre>\n";
                die();
            }
            wait(25);
        }
    }
    print "</p>\n";
    print '<p class="center">The database was updated successfully.</p>';
    print '<p class="center"><a href="../index.php">phpMyFAQ</a></p>';
    print '<p class="center">Please remove the backup (*.php.bak and *.bak.php) files located in the directory inc/.</p>';

    if (@unlink(basename($_SERVER["PHP_SELF"]))) {
        print "<p class=\"center\">This file was deleted automatically.</p>\n";
    } else {
        print "<p class=\"center\">Please delete this file manually.</p>\n";
    }
    if (@unlink(dirname($_SERVER["PATH_TRANSLATED"])."/installer.php")) {
        print "<p class=\"center\">The file 'installer.php' was deleted automatically.</p>\n";
    } else {
        print "<p class=\"center\">Please delete the file 'installer.php' manually.</p>\n";
    }
}
?>
<p class="center"><?php print COPYRIGHT; ?></p>
</body>
</html>

oder würde es gehen, das update einfach nochmal fpr die 1.4er version zu machen?

vielen dank schonmal,

carhartt
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

hast du die 1.4er noch?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
carhartt
Posts: 105
Joined: Mon Sep 08, 2003 12:46 pm

Post by carhartt »

vielleicht, müsste heute abend auf dem anderen rechner nochmal schaun...

carhartt
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

den Code gibts ja auf unserer Seite, die DB in der 1.4.11er Struktur wäre wichtig.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
carhartt
Posts: 105
Joined: Mon Sep 08, 2003 12:46 pm

Post by carhartt »

die dateien hätt ich auch noch, aber leider keinen sql-dump :cry:
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

schick mir mal deinen Dump, dann kann ich mal sehen, wie der aussieht...

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
carhartt
Posts: 105
Joined: Mon Sep 08, 2003 12:46 pm

Post by carhartt »

irgendwie kann ich die pmf geschichten nicht gesondert vom rest der datenbank exportieren... und die datenbank ist 30MB groß, und enthält sensible daten :(

carhartt
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

mit phpMyAdmin kannst du doch die Tabellen selektieren...

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
carhartt
Posts: 105
Joined: Mon Sep 08, 2003 12:46 pm

Post by carhartt »

du hast post! :oops:
Post Reply