function updateDatabase($_version, $_dbManager, $_prefix)
{
    $versions = array("3.1.8.1", "3.1.8.2", "3.1.8.3", "3.1.8.4", "3.1.8.5", "3.1.8.6", "3.2.0.0", "3.2.0.1", "3.2.0.2", "3.2.0.3", "3.3.0.0", "3.3.1.0", "3.3.1.1", "3.3.1.2", "3.3.1.3", "3.3.2.0", "3.3.2.1", "3.3.2.2", "3.4.0.0", "4.0.0.0", "4.0.1.0", "4.0.1.1", "4.0.1.2", "4.1.0.0", "4.1.0.1", "4.1.0.2", "4.1.0.3", "4.1.0.4", "4.2.0.0", "4.2.0.1", "4.2.0.2", "4.2.0.3", "4.2.0.4", "4.2.0.5", "5.0.0.0", "5.0.1.0", "5.0.1.1", "5.0.1.2", "5.0.1.3", "5.0.1.4", "5.1.0.0", "5.1.1.0", "5.1.2.0", "5.1.2.1", "5.1.2.2", "5.1.2.3", "5.2.0.0", "5.2.0.1", "5.2.5.0", "5.2.5.1", "5.2.5.2");
    if ($_version == "3.3.2.3") {
        $_version = "3.3.2.2";
    }
    if (!in_array($_version, $versions)) {
        return "Invalid version! (" . $_version . ")";
    }
    while ($_version != VERSION) {
        if ($_version == $versions[3]) {
            $_version = $versions[4];
        }
        if ($_version == $versions[4]) {
            $_version = $versions[5];
        }
        if ($_version == $versions[5]) {
            $result = up_3186_3200($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[6];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[6]) {
            $result = up_3200_3201($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[7];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[7]) {
            $_version = $versions[9];
        }
        if ($_version == $versions[8]) {
            $_version = $versions[9];
        }
        if ($_version == $versions[9]) {
            $result = up_3203_3300($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[10];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[10]) {
            $result = up_3300_3310($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[11];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[11]) {
            $result = up_3310_3311($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[12];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[12]) {
            $result = up_3311_3312($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[13];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[13]) {
            $_version = $versions[14];
        }
        if ($_version == $versions[14]) {
            $result = up_3313_3320($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[15];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[15]) {
            $_version = $versions[16];
        }
        if ($_version == $versions[16]) {
            $_version = $versions[17];
        }
        if ($_version == $versions[17]) {
            $result = up_3322_3400($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[18];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[18]) {
            $result = up_3400_4000($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[19];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[19]) {
            $result = up_4000_4010($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[20];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[20]) {
            $_version = $versions[21];
        }
        if ($_version == $versions[21]) {
            $_version = $versions[22];
        }
        if ($_version == $versions[22]) {
            $result = up_4012_4100($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[23];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[23]) {
            $_version = $versions[24];
        }
        if ($_version == $versions[24]) {
            $result = up_4101_4102($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[25];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[25]) {
            $result = up_4102_4103($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[26];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[26]) {
            $_version = $versions[27];
        }
        if ($_version == $versions[27]) {
            $result = up_4104_4200($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[28];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[28]) {
            $result = up_4200_4201($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[29];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[29]) {
            $result = up_4201_4202($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[30];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[30]) {
            $_version = $versions[31];
        }
        if ($_version == $versions[31]) {
            $_version = $versions[32];
        }
        if ($_version == $versions[32]) {
            $_version = $versions[33];
        }
        if ($_version == $versions[33]) {
            $result = up_4205_5000($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[34];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[34]) {
            $_version = $versions[35];
        }
        if ($_version == $versions[35]) {
            $_version = $versions[36];
        }
        if ($_version == $versions[36]) {
            $_version = $versions[37];
        }
        if ($_version == $versions[37]) {
            $_version = $versions[38];
        }
        if ($_version == $versions[38]) {
            $_version = $versions[39];
        }
        if ($_version == $versions[39]) {
            $result = up_5014_5100($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[40];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[40]) {
            $result = up_5100_5110($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[41];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[41]) {
            $_version = $versions[42];
        }
        if ($_version == $versions[42]) {
            $_version = $versions[43];
        }
        if ($_version == $versions[43]) {
            $_version = $versions[44];
        }
        if ($_version == $versions[44]) {
            $result = up_5122_5123($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[45];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[45]) {
            $result = up_5123_5200($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[46];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[46]) {
            $_version = $versions[47];
        }
        if ($_version == $versions[47]) {
            $result = up_5201_5250($_prefix, $_dbManager);
            if ($result === TRUE) {
                $_version = $versions[48];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[48]) {
            $_version = $versions[49];
        }
        if ($_version == $versions[49]) {
            $_version = $versions[50];
        }
    }
    $_dbManager->Query(false, "UPDATE `" . DBManager::RealEscape($_prefix) . "info` SET `version`='" . VERSION . "'");
    return true;
}
function updateDatabase($_version, $_link, $_prefix)
{
    global $GROUPS;
    $versions = array("3.1.8.1", "3.1.8.2", "3.1.8.3", "3.1.8.4", "3.1.8.5", "3.1.8.6", "3.2.0.0", "3.2.0.1", "3.2.0.2", "3.2.0.3", "3.3.0.0", "3.3.1.0", "3.3.1.1", "3.3.1.2", "3.3.1.3", "3.3.2.0", "3.3.2.1", "3.3.2.2");
    if (!in_array($_version, $versions)) {
        return "Invalid version! (" . $_version . ")";
    }
    while ($_version != VERSION) {
        if ($_version == $versions[0]) {
            $_version = $versions[1];
        }
        if ($_version == $versions[1]) {
            $_version = $versions[2];
        }
        if ($_version == $versions[2]) {
            $result = up_3183_3184($_prefix, $_link);
            if ($result === TRUE) {
                $_version = $versions[3];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[3]) {
            $_version = $versions[4];
        }
        if ($_version == $versions[4]) {
            $_version = $versions[5];
        }
        if ($_version == $versions[5]) {
            $result = up_3186_3200($_prefix, $_link);
            if ($result === TRUE) {
                $_version = $versions[6];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[6]) {
            $result = up_3200_3201($_prefix, $_link);
            if ($result === TRUE) {
                $_version = $versions[7];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[7]) {
            $_version = $versions[9];
        }
        if ($_version == $versions[8]) {
            $_version = $versions[9];
        }
        if ($_version == $versions[9]) {
            $result = up_3203_3300($_prefix, $_link);
            if ($result === TRUE) {
                $_version = $versions[10];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[10]) {
            $result = up_3300_3310($_prefix, $_link);
            if ($result === TRUE) {
                $_version = $versions[11];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[11]) {
            $result = up_3310_3311($_prefix, $_link);
            if ($result === TRUE) {
                $_version = $versions[12];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[12]) {
            $result = up_3311_3312($_prefix, $_link);
            if ($result === TRUE) {
                $_version = $versions[13];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[13]) {
            $_version = $versions[14];
        }
        if ($_version == $versions[14]) {
            $result = up_3313_3320($_prefix, $_link);
            if ($result === TRUE) {
                $_version = $versions[15];
            } else {
                return $result;
            }
        }
        if ($_version == $versions[15]) {
            $_version = $versions[16];
        }
        if ($_version == $versions[16]) {
            $_version = $versions[17];
        }
    }
    @mysql_query("UPDATE `" . @mysql_real_escape_string($_prefix) . "info` SET `version`='" . VERSION . "'", $_link);
    return true;
}