コード例 #1
0
ファイル: index.php プロジェクト: hostellerie/nexpro
/**
 * Sets up the database tables
 *
 * @return  boolean                 True if successful
 *
 */
function INST_createDatabaseStructures()
{
    global $_CONF, $_TABLES, $_DB, $_DB_dbms, $_DB_host, $_DB_user, $_DB_pass, $site_url, $use_innodb;
    $_DB->setDisplayError(true);
    // Because the create table syntax can vary from dbms-to-dbms we are
    // leaving that up to each database driver (e.g. mysql.class.php,
    // postgresql.class.php, etc)
    // Get DBMS-specific create table array and data array
    require_once $_CONF['path'] . 'sql/' . $_DB_dbms . '_tableanddata.php';
    $progress = '';
    if (INST_checkTableExists('access')) {
        return false;
    }
    switch ($_DB_dbms) {
        case 'mysql':
            INST_updateDB($_SQL);
            if ($use_innodb) {
                DB_query("INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('database_engine', 'InnoDB')");
            }
            break;
        case 'mssql':
            foreach ($_SQL as $sql) {
                $_DB->dbQuery($sql, 0, 1);
            }
            break;
    }
    // Now insert mandatory data and a small subset of initial data
    foreach ($_DATA as $data) {
        $progress .= "executing " . $data . "<br" . XHTML . ">\n";
        DB_query($data);
    }
    return true;
}
コード例 #2
0
ファイル: install.lib.php プロジェクト: spacequad/glfusion
/**
 * Perform database upgrades
 *
 * @param   string  $current_gl_version Current glFusion version
 * @param   boolean $use_innodb         Whether or not to use InnoDB support with MySQL
 * @return  boolean                     True if successful
 *
 */
function INST_doDatabaseUpgrades($current_fusion_version, $use_innodb = false)
{
    global $_TABLES, $_CONF, $_SYSTEM, $_SP_CONF, $_DB, $_DB_dbms, $_DB_table_prefix, $LANG_AM, $dbconfig_path, $siteconfig_path, $html_path, $LANG_INSTALL;
    global $_GLFUSION;
    $rc = true;
    $errors = '';
    $_DB->setDisplayError(true);
    // Because the upgrade sql syntax can vary from dbms-to-dbms we are
    // leaving that up to each glFusion database driver
    $progress = '';
    switch ($current_fusion_version) {
        case '1.0.0':
        case '1.0.1':
        case '1.0.2':
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.0.1_to_1.1.0.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.0.1_to_1.1.0.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            // index cleanup...
            $_SQLi = array();
            $_SQLi[] = "ALTER TABLE {$_TABLES['blocks']} DROP INDEX blocks_bid";
            $_SQLi[] = "ALTER TABLE {$_TABLES['events']} DROP INDEX events_eid";
            $_SQLi[] = "ALTER TABLE {$_TABLES['group_assignments']} DROP INDEX ug_main_grp_id";
            $_SQLi[] = "ALTER TABLE {$_TABLES['sessions']} DROP INDEX sess_id";
            $_SQLi[] = "ALTER TABLE {$_TABLES['stories']} DROP INDEX stories_sid";
            $_SQLi[] = "ALTER TABLE {$_TABLES['userindex']} DROP INDEX userindex_uid";
            if (isset($_TABLES['polltopics'])) {
                $_SQLi[] = "ALTER TABLE {$_TABLES['polltopics']} DROP INDEX pollquestions_pid";
            }
            foreach ($_SQLi as $sqli) {
                $rc = DB_query($sqli, 1);
            }
            $_SQLi = array();
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('comment_code', 0, 'select', 4, 21, 17, 1670, TRUE);
            $c->add('comment_edit', 0, 'select', 4, 21, 0, 1680, TRUE);
            $c->add('comment_edittime', 1800, 'text', 4, 21, NULL, 1690, TRUE);
            $c->add('article_comment_close_days', 30, 'text', 4, 21, NULL, 1700, TRUE);
            $c->add('comment_close_rec_stories', 0, 'text', 4, 21, NULL, 1710, TRUE);
            $c->add('image_lib', 'gdlib', 'select', 5, 22, 10, 1450, TRUE);
            $c->add('jhead_enabled', 0, 'select', 5, 22, 0, 1480, TRUE);
            $c->add('path_to_jhead', '', 'text', 5, 22, NULL, 1490, TRUE);
            $c->add('jpegtrans_enabled', 0, 'select', 5, 22, 0, 1500, TRUE);
            $c->add('path_to_jpegtrans', '', 'text', 5, 22, NULL, 1510, TRUE);
            $c->add('hide_adminmenu', TRUE, 'select', 3, 12, 1, 1170, TRUE);
            $c->add('fs_search', NULL, 'fieldset', 0, 6, NULL, 0, TRUE);
            $c->add('search_style', 'google', 'select', 0, 6, 18, 650, TRUE);
            $c->add('search_limits', '10,15,25,30', 'text', 0, 6, NULL, 660, TRUE);
            $c->add('num_search_results', 25, 'text', 0, 6, NULL, 670, TRUE);
            $c->add('search_show_limit', TRUE, 'select', 0, 6, 1, 680, TRUE);
            $c->add('search_show_sort', TRUE, 'select', 0, 6, 1, 690, TRUE);
            $c->add('search_show_num', TRUE, 'select', 0, 6, 1, 700, TRUE);
            $c->add('search_show_type', TRUE, 'select', 0, 6, 1, 710, TRUE);
            $c->add('search_show_user', TRUE, 'select', 0, 6, 1, 720, TRUE);
            $c->add('search_show_hits', TRUE, 'select', 0, 6, 1, 730, TRUE);
            $c->add('search_no_data', '<i>Not available...</i>', 'text', 0, 6, NULL, 740, TRUE);
            $c->add('search_separator', ' &gt; ', 'text', 0, 6, NULL, 750, TRUE);
            $c->add('search_def_keytype', 'phrase', 'select', 0, 6, 19, 760, TRUE);
            $c->add('default_search_order', 'date', 'select', 0, 6, 22, 770, TRUE);
            $c->add('search_use_fulltext', FALSE, 'hidden', 0, 6);
            $c->add('mail_backend', 'mail', 'select', 0, 1, 20, 60, TRUE);
            $c->add('mail_sendmail_path', '', 'text', 0, 1, NULL, 70, TRUE);
            $c->add('mail_sendmail_args', '', 'text', 0, 1, NULL, 80, TRUE);
            $c->add('mail_smtp_host', '', 'text', 0, 1, NULL, 90, TRUE);
            $c->add('mail_smtp_port', '', 'text', 0, 1, NULL, 100, TRUE);
            $c->add('mail_smtp_auth', FALSE, 'select', 0, 1, 0, 110, TRUE);
            $c->add('mail_smtp_username', '', 'text', 0, 1, NULL, 120, TRUE);
            $c->add('mail_smtp_password', '', 'text', 0, 1, NULL, 130, TRUE);
            $c->add('mail_smtp_secure', 'none', 'select', 0, 1, 21, 140, TRUE);
            $c->add('compress_css', TRUE, 'select', 2, 11, 0, 1370, TRUE);
            $c->add('allow_embed_object', TRUE, 'select', 7, 34, 1, 1720, TRUE);
            $c->add('digg_enabled', 1, 'select', 1, 7, 0, 1235, TRUE);
            // now delete the old setting - we don't want it anymore...
            $c->del('mail_settings', 'Core');
            $c->del('use_safe_html', 'Core');
            $c->del('user_html', 'Core');
            $c->del('admin_html', 'Core');
            $c->del('allowed_protocols', 'Core');
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.0',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.0' WHERE name='glfusion'", 1);
            $current_fusion_version = '1.1.0';
            $_SQL = array();
        case '1.1.0':
        case '1.1.1':
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('story_submit_by_perm_only', 0, 'select', 4, 20, 0, 780, TRUE);
            $c->add('use_from_site_mail', 0, 'select', 0, 1, 0, 150, TRUE);
            $c->del('pdf_enabled', 'Core');
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.2',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.2' WHERE name='glfusion'", 1);
            $current_fusion_version = '1.1.2';
        case '1.1.2':
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.2_to_1.1.3.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.1.2_to_1.1.3.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('hidestorydate', 0, 'select', 1, 7, 0, 1205, TRUE);
            $c->add('fs_caching', NULL, 'fieldset', 2, 12, NULL, 0, TRUE);
            $c->add('cache_templates', 1, 'select', 2, 12, 0, 1375, TRUE);
            $c->add('template_comments', FALSE, 'select', 2, 11, 0, 1373, TRUE);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.3',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.3' WHERE name='glfusion'", 1);
            $current_fusion_version = '1.1.3';
        case '1.1.3':
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.3_to_1.1.4.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.1.3_to_1.1.4.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.4',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.4' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.1.4';
        case '1.1.4':
            DB_query("ALTER TABLE {$_TABLES['stories']} DROP INDEX stories_in_transit", 1);
            DB_query("ALTER TABLE {$_TABLES['stories']} DROP COLUMN in_transit", 1);
            DB_query("ALTER TABLE {$_TABLES['userprefs']} ADD search_result_format VARCHAR( 48 ) NOT NULL DEFAULT 'google'", 1);
            DB_query("UPDATE {$_TABLES['conf_values']} SET type='text' WHERE name='mail_smtp_host'", 1);
            DB_query("UPDATE {$_TABLES['conf_values']} SET selectionArray='23' WHERE name='censormode'", 1);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.5',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.5' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('hide_exclude_content', 0, 'select', 4, 16, 0, 295, TRUE);
            $c->add('maintenance_mode', 0, 'select', 0, 0, 0, 520, TRUE);
            $c->del('search_show_limit', 'Core');
            $c->del('search_show_sort', 'Core');
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.4_to_1.1.5.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.1.4_to_1.1.5.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            $current_fusion_version = '1.1.5';
        case '1.1.5':
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.6',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.6' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.1.6';
        case '1.1.6':
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.6_to_1.1.7.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.1.6_to_1.1.7.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('rating_enabled', 1, 'select', 1, 7, 24, 1237, TRUE);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.7',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.7' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.1.7';
        case '1.1.7':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('user_reg_fullname', 1, 'select', 4, 19, 25, 980, TRUE);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.8',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.8' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.1.8';
        case '1.1.8':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('article_comment_close_enabled', 0, 'select', 4, 21, 0, 1695, TRUE);
            $session_ip_check = 1;
            if (isset($_SYSTEM['skip_ip_check']) && $_SYSTEM['skip_ip_check'] == 1) {
                $session_ip_check = 0;
            }
            $c->add('session_ip_check', $session_ip_check, 'select', 7, 30, 26, 545, TRUE);
            $c->del('default_search_order', 'Core');
            DB_query("UPDATE {$_TABLES['conf_values']} SET selectionArray = '0' WHERE  name='searchloginrequired' AND group_name='Core'");
            DB_query("ALTER TABLE {$_TABLES['groups']} ADD grp_default tinyint(1) unsigned NOT NULL default '0' AFTER grp_gl_core");
            DB_query("ALTER TABLE {$_TABLES['users']} CHANGE `passwd` `passwd` VARCHAR( 40 ) NOT NULL default ''");
            // clean up group names and assign proper admin setting
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='Bad Behavior2 Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_name='calendar Admin' WHERE grp_name='Calendar Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='calendar Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='filemgmt Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='forum Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_name='links Admin' WHERE grp_name='Links Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='links Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='mediagallery Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_name='polls Admin' WHERE grp_name='Polls Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='polls Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='sitetailor Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_name='staticpages Admin' WHERE grp_name='Static Page Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='staticpages Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='spamx Admin'", 1);
            // move multi-language support to its own fieldset
            DB_query("INSERT INTO {$_TABLES['conf_values']} (name,value,type,group_name,default_value,subgroup,selectionArray,sort_order,fieldset) VALUES ('fs_mulitlanguage','N;','fieldset','Core','N;',6,-1,0,41)", 1);
            DB_query("UPDATE {$_TABLES['conf_values']} SET fieldset='41' WHERE name='language_files' AND group_name='Core'", 1);
            DB_query("UPDATE {$_TABLES['conf_values']} SET fieldset='41' WHERE name='languages' AND group_name='Core'", 1);
            // topic sort
            DB_query("ALTER TABLE {$_TABLES['topics']} ADD sort_by TINYINT(1) NOT NULL DEFAULT '0' AFTER archive_flag", 1);
            DB_query("ALTER TABLE {$_TABLES['topics']} ADD sort_dir CHAR( 4 ) NOT NULL DEFAULT 'DESC' AFTER sort_by", 1);
            // new stats.view permission
            DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('stats.view','Allows access to the Stats page.',0)", 1);
            $ft_id = DB_insertId();
            $all_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'All Users'"));
            $loggedin_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Logged-in Users'"));
            $root_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'"));
            if ($_CONF['statsloginrequired'] || $_CONF['loginrequired']) {
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$loggedin_grp_id})", 1);
            } else {
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$all_grp_id})", 1);
            }
            DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$root_grp_id})", 1);
            $c->del('statsloginrequired', 'Core');
            $c->add('registration_type', 0, 'select', 4, 19, 27, 785, TRUE, 'Core');
            DB_query("ALTER TABLE {$_TABLES['users']} ADD act_token VARCHAR(32) NOT NULL DEFAULT '' AFTER pwrequestid", 1);
            DB_query("ALTER TABLE {$_TABLES['users']} ADD act_time DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00.000000' AFTER act_token", 1);
            $c->del('cookie_ip', 'Core');
            DB_query("ALTER TABLE {$_TABLES['sessions']} DROP PRIMARY KEY", 1);
            DB_query("ALTER TABLE {$_TABLES['sessions']} ADD PRIMARY KEY (md5_sess_id)", 1);
            $c->add('comment_postmode', 'plaintext', 'select', 4, 21, 5, 1693, TRUE);
            $c->add('comment_editor', 0, 'select', 4, 21, 28, 1694, TRUE);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.2.0',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.2.0' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.2.0';
        case '1.2.0':
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.2.1',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.2.1' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.2.1';
        case '1.2.1':
        case '1.2.2':
        case '1.2.3':
            require_once $_CONF['path'] . 'sql/updates/mysql_1.2.2_to_1.3.0.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            // logo
            $c->add('fs_logo', NULL, 'fieldset', 5, 28, NULL, 0, TRUE);
            $c->add('max_logo_height', 150, 'text', 5, 28, NULL, 1630, TRUE);
            $c->add('max_logo_width', 500, 'text', 5, 28, NULL, 1640, TRUE);
            // whats new cache time
            $c->add('whatsnew_cache_time', 3600, 'text', 3, 15, NULL, 1060, TRUE);
            // add user photo option to whosonline block
            $c->add('whosonline_photo', FALSE, 'select', 3, 14, 0, 930, TRUE);
            // remove old wikitext configuration
            $c->del('wikitext_editor', 'Core');
            // add oauth user_login_method
            $c->del('user_login_method', 'Core');
            // delete microsummary
            $c->del('microsummary_short', 'Core');
            $standard = $_CONF['user_login_method']['standard'] ? true : false;
            $thirdparty = $_CONF['user_login_method']['3rdparty'] ? true : false;
            // OAuth configuration settings
            $oauth = false;
            $c->add('user_login_method', array('standard' => $standard, '3rdparty' => $thirdparty, 'oauth' => $oauth), '@select', 4, 16, 1, 320, TRUE);
            $c->add('facebook_login', 0, 'select', 4, 16, 1, 330, TRUE);
            $c->add('facebook_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 335, TRUE);
            $c->add('facebook_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 340, TRUE);
            $c->add('linkedin_login', 0, 'select', 4, 16, 1, 345, TRUE);
            $c->add('linkedin_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 350, TRUE);
            $c->add('linkedin_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 355, TRUE);
            $c->add('twitter_login', 0, 'select', 4, 16, 1, 360, TRUE);
            $c->add('twitter_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 365, TRUE);
            $c->add('twitter_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 370, TRUE);
            $c->add('google_login', 0, 'select', 4, 16, 1, 375, TRUE);
            $c->add('google_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 380, TRUE);
            $c->add('google_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 385, TRUE);
            $c->add('microsoft_login', 0, 'select', 4, 16, 1, 390, TRUE);
            $c->add('microsoft_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 395, TRUE);
            $c->add('microsoft_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 400, TRUE);
            // date / time format changes
            $c->add('date', 'l, F d Y @ h:i A T', 'text', 6, 29, NULL, 370, TRUE);
            $c->add('daytime', 'm/d h:iA', 'text', 6, 29, NULL, 380, TRUE);
            $c->add('shortdate', 'm/d/y', 'text', 6, 29, NULL, 390, TRUE);
            $c->add('dateonly', 'd-M', 'text', 6, 29, NULL, 400, TRUE);
            $c->add('timeonly', 'H:iA', 'text', 6, 29, NULL, 410, TRUE);
            // hide what's new if empty
            $c->add('hideemptyblock', 0, 'select', 3, 15, 0, 1045, TRUE);
            // update check
            $c->add('fs_update', NULL, 'fieldset', 0, 7, NULL, 0, TRUE);
            $c->add('update_check_interval', '86400', 'select', 0, 7, 29, 765, TRUE);
            $c->add('send_site_data', TRUE, 'select', 0, 7, 1, 770, TRUE);
            // rating
            $c->add('fs_rating', NULL, 'fieldset', 4, 7, NULL, 0, TRUE);
            $c->add('rating_speedlimit', 15, 'text', 4, 7, NULL, 10, TRUE);
            // add new logo.admin permission
            $result = DB_query("SELECT * FROM {$_TABLES['features']} WHERE ft_name='logo.admin'");
            if (DB_numRows($result) == 0) {
                DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('logo.admin','Ability to modify site logo',1)", 1);
                $ft_id = DB_insertId();
                $grp_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'");
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$grp_id})", 1);
            }
            // add new menu.admin permission
            $result = DB_query("SELECT * FROM {$_TABLES['features']} WHERE ft_name='menu.admin'");
            if (DB_numRows($result) == 0) {
                DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('menu.admin','Ability to create/edit site menus',1)", 1);
                $ft_id = DB_insertId();
                $grp_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'");
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$grp_id})", 1);
            }
            // add new autotag features
            $autotag_admin_ft_id = 0;
            $autotag_php_ft_id = 0;
            $autotag_group_id = 0;
            $tmp_admin_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'autotag.admin'");
            if (empty($tmp_admin_ft_id)) {
                DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('autotag.admin','Ability to create / edit autotags',1)", 1);
                $autotag_admin_ft_id = DB_insertId();
            }
            $tmp_php_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'autotag.PHP'");
            if (empty($tmp_php_ft_id)) {
                DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('autotag.PHP','Ability to create / edit autotags utilizing PHP functions',1)", 1);
                $autotag_php_ft_id = DB_insertId();
            }
            // now check for the group
            $result = DB_query("SELECT * FROM {$_TABLES['groups']} WHERE grp_name='Autotag Admin'");
            if (DB_numRows($result) == 0) {
                DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core, grp_default) VALUES ('Autotag Admin','Has full access to create and modify autotags',1,0)");
                $autotag_group_id = DB_insertId();
            }
            if ($autotag_admin_ft_id != 0 && $autotag_group_id != 0) {
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $autotag_admin_ft_id . "," . $autotag_group_id . ")");
            }
            if ($autotag_php_ft_id != 0 && $autotag_group_id != 0) {
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $autotag_php_ft_id . "," . $autotag_group_id . ")");
            }
            if ($autotag_group_id != 0) {
                DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id,ug_grp_id) VALUES (" . $autotag_group_id . ",1)");
            }
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.3.0',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.3.0' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.3.0';
        case '1.3.0':
            $current_fusion_version = '1.3.1';
        case '1.3.1':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $current_fusion_version = '1.3.2';
        case '1.3.2':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            // remove menu_elements - no longer used
            $c->del('menu_elements', 'Core');
            $c->del('mailstory_postmode', 'Core');
            $c->del('comment_editor', 'Core');
            $c->del('advanced_editor', 'Core');
            if (!isset($_CONF['mailuser_postmode'])) {
                $c->add('mailuser_postmode', 'html', 'select', 4, 5, 5, 43, TRUE);
            }
            // set the initial set of html elements
            if (!isset($_CONF['htmlfilter_comment'])) {
                $c->add('htmlfilter_default', 'p,b,a,i,strong,em,br', 'text', 7, 5, NULL, 30, true);
                $c->add('htmlfilter_comment', 'p,b,a,i,strong,em,br,tt,hr,li,ol,ul,code,pre', 'text', 7, 5, NULL, 35, TRUE);
                $c->add('htmlfilter_story', 'div[class],h1,h2,h3,pre,br,p[style],b[style],s,strong[style],i[style],em[style],u[style],strike,a[style|href|title|target],ol[style|class],ul[style|class],li[style|class],hr[style],blockquote[style],img[style|alt|title|width|height|src|align],table[style|width|bgcolor|align|cellspacing|cellpadding|border],tr[style],td[style],th[style],tbody,thead,caption,col,colgroup,span[style|class],sup,sub', 'text', 7, 5, NULL, 40, TRUE);
                $c->add('htmlfilter_root', 'div[style|class],span[style|class],table,tr,td,th', 'text', 7, 5, NULL, 50, TRUE);
            }
            $sql = "REPLACE INTO {$_TABLES['autotags']} (tag, description, is_enabled, is_function, replacement) VALUES ('youtube', 'Embed Youtube videos into content. Usage:[youtube:ID height:px width:px align:left/right/center pad:px]', 1, 1, NULL)";
            DB_query($sql, 1);
            $current_fusion_version = '1.4.0';
        case '1.4.0':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('github_login', 0, 'select', 4, 1, 1, 271, TRUE);
            $c->add('github_consumer_key', 'not configured yet', 'text', 4, 1, NULL, 272, TRUE);
            $c->add('github_consumer_secret', 'not configured yet', 'text', 4, 1, NULL, 273, TRUE);
            $current_fusion_version = '1.4.1';
        case '1.4.1':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $current_fusion_version = '1.4.2';
        case '1.4.2':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('min_username_length', '4', 'text', 4, 4, NULL, 60, TRUE);
            $current_fusion_version = '1.4.3';
        case '1.4.3':
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `alternate_tid` VARCHAR(20) NULL DEFAULT NULL AFTER `tid`, ADD INDEX `alternate_topic` (`alternate_tid`) ;";
            $_SQL[] = "ALTER TABLE {$_TABLES['tokens']} CHANGE `urlfor` `urlfor` VARCHAR( 1024 ) NOT NULL";
            $_SQL[] = "ALTER TABLE {$_TABLES['comments']} CHANGE  `ipaddress`  `ipaddress` VARCHAR( 45 ) NOT NULL DEFAULT  ''";
            $_SQL[] = "ALTER TABLE {$_TABLES['rating_votes']} CHANGE  `ip_address`  `ip_address` VARCHAR( 45 ) NOT NULL";
            $_SQL[] = "ALTER TABLE {$_TABLES['sessions']} CHANGE  `remote_ip`  `remote_ip` VARCHAR( 45 ) NOT NULL DEFAULT  ''";
            $_SQL[] = "ALTER TABLE {$_TABLES['trackback']}  `ipaddress`  `ipaddress` VARCHAR( 45 ) NOT NULL DEFAULT  ''";
            $_SQL[] = "ALTER TABLE {$_TABLES['users']} CHANGE  `remote_ip`  `remote_ip` VARCHAR( 45 ) NOT NULL DEFAULT  ''";
            $_SQL[] = "ALTER TABLE {$_TABLES['topics']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT '';";
            $_SQL[] = "ALTER TABLE {$_TABLES['topics']} CHANGE `topic` `topic` VARCHAR(128) NULL DEFAULT NULL;";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'General';";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `alternate_tid` `alternate_tid` VARCHAR(128) NULL DEFAULT NULL;";
            $_SQL[] = "ALTER TABLE {$_TABLES['blocks']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'All';";
            $_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'General';";
            foreach ($_SQL as $sql) {
                DB_query($sql, 1);
            }
            $result = DB_query("SELECT * FROM {$_TABLES['autotags']} WHERE tag='uikitlogin'");
            if (DB_numRows($result) < 1) {
                $sql = "INSERT INTO {$_TABLES['autotags']} (`tag`, `description`, `is_enabled`, `is_function`, `replacement`) VALUES ('uikitlogin', 'UIKit Login Widget', '1', '1', NULL);";
                DB_query($sql, 1);
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $current_fusion_version = '1.5.0';
        case '1.5.0':
            $_SQL[] = "ALTER TABLE {$_TABLES['article_images']} CHANGE `ai_sid` `ai_sid` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['comments']} CHANGE `sid` `sid` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `sid` `sid` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} CHANGE `sid` `sid` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['syndication']} CHANGE `topic` `topic` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['trackback']} CHANGE `sid` `sid` VARCHAR(128);";
            foreach ($_SQL as $sql) {
                DB_query($sql, 1);
            }
            $current_fusion_version = '1.5.1';
        case '1.5.1':
        case '1.5.2':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('infinite_scroll', 1, 'select', 1, 1, 0, 25, TRUE);
            $c->add('comment_engine', 'internal', 'select', 4, 6, 30, 1, TRUE);
            $c->add('comment_disqus_shortname', 'not defined', 'text', 4, 6, NULL, 2, TRUE);
            $c->add('comment_fb_appid', 'not defined', 'text', 4, 6, NULL, 3, TRUE);
            $c->add('social_site_extra', '', 'text', 0, 0, NULL, 1, TRUE, 'social_internal');
            $c->add('fb_appid', '', 'text', 0, 0, NULL, 90, TRUE);
            // remove openid
            $sql = "SELECT * FROM {$_TABLES['conf_values']} WHERE name='user_login_method' AND group_name='Core'";
            $result = DB_query($sql, 1);
            if (DB_numRows($result) > 0) {
                $row = DB_fetchArray($result);
                $methods = @unserialize($row['value']);
                $standard = $methods['standard'] ? true : false;
                $thirdparty = $methods['3rdparty'] ? true : false;
                $oauth = $methods['oauth'] ? true : false;
                if ($standard === false && $thirdparty === false && $oauth === false) {
                    $standard = true;
                }
                $c->del('user_login_method', 'Core');
                $c->add('user_login_method', array('standard' => $standard, '3rdparty' => $thirdparty, 'oauth' => $oauth), '@select', 4, 1, 1, 120, TRUE);
            }
            DB_query("ALTER TABLE {$_TABLES['subscriptions']} DROP INDEX `type`", 1);
            DB_query("DROP INDEX `trackback_url` ON {$_TABLES['trackback']};", 1);
            $_SQL = array();
            $_SQL[] = "ALTER TABLE {$_TABLES['sessions']} CHANGE `md5_sess_id` `md5_sess_id` VARCHAR(128) NOT NULL DEFAULT '';";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `subtitle` VARCHAR(128) DEFAULT NULL AFTER `title`;";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `story_image` VARCHAR(128) DEFAULT NULL AFTER `alternate_tid`;";
            $_SQL[] = "UPDATE {$_TABLES['plugins']} SET pi_enabled='0' WHERE pi_name='ban'";
            $_SQL[] = "ALTER TABLE {$_TABLES['autotags']} CHANGE `description` `description` VARCHAR(250) NULL DEFAULT '';";
            $_SQL[] = "REPLACE INTO {$_TABLES['autotags']} (tag, description, is_enabled, is_function, replacement) VALUES ('vimeo', 'Embed Vimeo videos into content. Usage:[vimeo:ID height:PX width:PX align:LEFT/RIGHT pad:PX responsive:0/1]', 1, 1, NULL)";
            $_SQL[] = "REPLACE INTO {$_TABLES['autotags']} (tag, description, is_enabled, is_function, replacement) VALUES ('newimage', 'HTML: embeds new images in flexible grid. usage: [newimage:<i>#</i> - How many images to display <i>truncate:0/1</i> - 1 = truncate number of images to keep square grid <i>caption:0/1</i> 1 = include title]', 1, 1, '');";
            $_SQL[] = "ALTER TABLE {$_TABLES['rating']} CHANGE `item_id` `item_id` VARCHAR(128) NOT NULL DEFAULT '';";
            $_SQL[] = "ALTER TABLE {$_TABLES['rating_votes']} CHANGE `item_id` `item_id` VARCHAR(128) NOT NULL DEFAULT '';";
            $_SQL[] = "ALTER TABLE {$_TABLES['subscriptions']} CHANGE `id` `id` VARCHAR(128) NOT NULL DEFAULT '';";
            $_SQL[] = "CREATE TABLE `{$_TABLES['social_share']}` (\n              `id` varchar(128) NOT NULL DEFAULT '',\n              `name` varchar(128) NOT NULL DEFAULT '',\n              `display_name` varchar(128) NOT NULL DEFAULT '',\n              `icon` varchar(128) NOT NULL DEFAULT '',\n              `url` varchar(128) NOT NULL DEFAULT '',\n              `enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',\n              PRIMARY KEY (id)\n            ) ENGINE=MyISAM;\n            ";
            $_SQL[] = "CREATE TABLE {$_TABLES['social_follow_services']} (\n              `ssid` int(10) UNSIGNED NOT NULL auto_increment,\n              `url` varchar(128) NOT NULL DEFAULT '',\n              `enabled` tinyint(1) NOT NULL DEFAULT '1',\n              `icon` varchar(128) NOT NULL,\n              `service_name` varchar(128) NOT NULL,\n              `display_name` varchar(128) NOT NULL,\n              UNIQUE KEY `ssid` (`ssid`),\n              UNIQUE KEY `service_name` (`service_name`)\n            ) ENGINE=MyISAM;";
            $_SQL[] = "CREATE TABLE {$_TABLES['social_follow_user']} (\n              `suid` int(10) NOT NULL AUTO_INCREMENT,\n              `ssid` int(11) NOT NULL DEFAULT '0',\n              `uid` int(11) NOT NULL,\n              `ss_username` varchar(128) NOT NULL DEFAULT '',\n              UNIQUE KEY `suid` (`suid`),\n              UNIQUE KEY `ssid` (`ssid`,`uid`)\n            ) ENGINE=MyISAM;";
            $_SQL[] = "ALTER TABLE {$_TABLES['rating']} CHANGE `type` `type` varchar(30) NOT NULL DEFAULT '';";
            $_SQL[] = "ALTER TABLE {$_TABLES['rating_votes']} CHANGE `type` `type` varchar(30) NOT NULL DEFAULT '';";
            $_SQL[] = "ALTER TABLE {$_TABLES['subscriptions']} CHANGE `type` `type` varchar(30) NOT NULL DEFAULT '';";
            $_SQL[] = "ALTER TABLE {$_TABLES['logo']} CHANGE `config_name` `config_name` varchar(128) DEFAULT NULL;";
            list($rc, $errors) = INST_updateDB($_SQL);
            $_DATA = array();
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('fb', 'facebook', 'Facebook', 'facebook', 'http://www.facebook.com/sharer.php?s=100', 1);";
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('gg', 'google-plus', 'Google+', 'google-plus', 'https://plus.google.com/share?url', 1);";
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('li', 'linkedin', 'LinkedIn', 'linkedin', 'http://www.linkedin.com', 1);";
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('lj', 'livejournal', 'Live Journal', 'pencil', 'http://www.livejournal.com', 1);";
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('mr', 'mail-ru', 'Mail.ru', 'at', 'http://mail-ru.com', 1);";
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('ok', 'odnoklassniki', 'Odnoklassniki', 'odnoklassniki', 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1', 1);";
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('pt', 'pinterest', 'Pinterest', 'pinterest-p', 'http://www.pinterest.com', 1);";
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('rd', 'reddit', 'reddit', 'reddit-alien', 'http://reddit.com/submit?url=%%u&title=%%t', 1);";
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('tw', 'twitter', 'Twitter', 'twitter', 'http://www.twitter.com', 1);";
            $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('vk', 'vk', 'vk', 'vk', 'http://www.vk.org', 1);";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(1, 'https://twitter.com/%%u', 1, 'twitter', 'twitter', 'Twitter');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(2, 'http://facebook.com/%%u', 1, 'facebook', 'facebook', 'Facebook');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(3, 'http://pinterest.com/%%u', 1, 'pinterest-p', 'pinterest', 'Pinterest');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(4, 'http://youtube.com/%%u', 1, 'youtube', 'youtube', 'Youtube');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(5, 'http://plus.google.com/+%%u', 1, 'google-plus', 'google-plus', 'Google+');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(6, 'http://linkedin.com/in/%%u', 1, 'linkedin', 'linkedin', 'LinkedIn');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(7, 'http://linkedin.com/company/%%u', 1, 'linkedin-square', 'linkedin-co', 'LinkedIn (Company)');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(8, 'http://github.com/%%u', 1, 'github', 'github', 'GitHub');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(9, 'http://instagram.com/%%u', 1, 'instagram', 'instagram', 'Instagram');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(10, 'http://vimeo.com/%%u', 1, 'vimeo', 'vimeo', 'Vimeo');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(11, 'http://flickr.com/photos/%%u', 1, 'flickr', 'flickr', 'Flickr');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(12, 'http://foursquare.com/%%u', 1, 'foursquare', 'foursquare', 'Foursquare');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(13, 'http://yelp.com/biz/%%u', 1, 'yelp', 'yelp', 'Yelp');";
            $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(14, 'http://dribbble.com/%%u', 1, 'dribbble', 'dribbble', 'Dribbble');";
            $_DATA[] = "REPLACE INTO " . $_TABLES['autotags'] . " (tag, description, is_enabled, is_function, replacement) VALUES ('headlines', 'HTML: embeds article headslines. usage: [headlines:<i>topic_name or all</i> display:## meta:0/1 titlelink:0/1 featured:0/1 frontpage:0/1 cols:# template:template_name]', 1, 1, '');";
            $_DATA[] = "REPLACE INTO " . $_TABLES['autotags'] . " (tag, description, is_enabled, is_function, replacement) VALUES ('mgslider', 'HTML: displays Media Gallery album. usage: [mgslider:<i>#album_id#</i> - Album ID for images <i>kenburns:0/1</i> - 1 = Enable Ken Burns effect <i>autoplay:0/1</i> 1 = Autoplay the slides <i>template:_name_</i> - Custom template name if wanted]', 1, 1, '');";
            $_DATA[] = "REPLACE INTO {$_TABLES['blocks']} (`bid`, `is_enabled`, `name`, `type`, `title`, `tid`, `blockorder`, `content`, `allow_autotags`, `rdfurl`, `rdfupdated`, `rdf_last_modified`, `rdf_etag`, `rdflimit`, `onleft`, `phpblockfn`, `help`, `owner_id`, `group_id`, `perm_owner`, `perm_group`, `perm_members`, `perm_anon`) VALUES(56, 1, 'followusblock', 'phpblock', 'Follow Us', 'all', 0, '', 0, '', '1000-01-01 00:00:00.000000', NULL, NULL, 0, 0, 'phpblock_social', '', 4, 4, 3, 2, 2, 2);";
            foreach ($_DATA as $sql) {
                DB_query($sql, 1);
            }
            // add new social features
            $sis_admin_ft_id = 0;
            $sis_group_id = 0;
            $tmp_admin_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'social.admin'");
            if (empty($tmp_admin_ft_id)) {
                DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('social.admin','Ability to manage social features.',1)", 1);
                $sis_admin_ft_id = DB_insertId();
            }
            // now check for the group
            $result = DB_query("SELECT * FROM {$_TABLES['groups']} WHERE grp_name='Social Admin'");
            if (DB_numRows($result) == 0) {
                DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core, grp_default) VALUES ('Social Admin','Has full access to manage social integrations.',1,0)");
                $sis_group_id = DB_insertId();
            }
            if ($sis_admin_ft_id != 0 && $sis_group_id != 0) {
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $sis_admin_ft_id . "," . $sis_group_id . ")");
            }
            if ($sis_group_id != 0) {
                DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id,ug_grp_id) VALUES (" . $sis_group_id . ",1)");
            }
            $current_fusion_version = '1.6.0';
        case '1.6.0':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->del('fs_mysql', 'Core');
            $c->del('allow_mysqldump', 'Core');
            $c->del('mysqldump_path', 'Core');
            $c->del('mysqldump_options', 'Core');
            $_SQL = array();
            $_SQL[] = "ALTER TABLE {$_TABLES['blocks']} CHANGE `title` `title` VARCHAR(255) NULL DEFAULT NULL;";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `attribution_url` VARCHAR(255) NOT NULL default '' AFTER `expire`;";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `attribution_name` VARCHAR(255) NOT NULL DEFAULT '' AFTER `attribution_url`;";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `attribution_author` VARCHAR(255) NOT NULL DEFAULT '' AFTER `attribution_name`;";
            list($rc, $errors) = INST_updateDB($_SQL);
            $current_fusion_version = '1.6.1';
        default:
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='" . $current_fusion_version . "',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='" . $current_fusion_version . "' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            break;
    }
    DB_query("ALTER TABLE {$_TABLES['userprefs']} ADD search_result_format VARCHAR( 48 ) NOT NULL DEFAULT 'google'", 1);
    // delete the security check flag on every update to force the user
    // to run admin/sectest.php again
    DB_delete($_TABLES['vars'], 'name', 'security_check');
    INST_resyncConfig();
    return array($rc, $errors);
}
コード例 #3
0
ファイル: install.lib.php プロジェクト: JohnToro/glfusion
/**
 * Perform database upgrades
 *
 * @param   string  $current_gl_version Current glFusion version
 * @param   boolean $use_innodb         Whether or not to use InnoDB support with MySQL
 * @return  boolean                     True if successful
 *
 */
function INST_doDatabaseUpgrades($current_fusion_version, $use_innodb = false)
{
    global $_TABLES, $_CONF, $_SYSTEM, $_SP_CONF, $_DB, $_DB_dbms, $_DB_table_prefix, $LANG_AM, $dbconfig_path, $siteconfig_path, $html_path, $LANG_INSTALL;
    global $_GLFUSION;
    $rc = true;
    $errors = '';
    $_DB->setDisplayError(true);
    // Because the upgrade sql syntax can vary from dbms-to-dbms we are
    // leaving that up to each glFusion database driver
    $progress = '';
    switch ($current_fusion_version) {
        case '1.0.0':
        case '1.0.1':
        case '1.0.2':
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.0.1_to_1.1.0.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.0.1_to_1.1.0.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            // index cleanup...
            $_SQLi = array();
            $_SQLi[] = "ALTER TABLE {$_TABLES['blocks']} DROP INDEX blocks_bid";
            $_SQLi[] = "ALTER TABLE {$_TABLES['events']} DROP INDEX events_eid";
            $_SQLi[] = "ALTER TABLE {$_TABLES['group_assignments']} DROP INDEX ug_main_grp_id";
            $_SQLi[] = "ALTER TABLE {$_TABLES['sessions']} DROP INDEX sess_id";
            $_SQLi[] = "ALTER TABLE {$_TABLES['stories']} DROP INDEX stories_sid";
            $_SQLi[] = "ALTER TABLE {$_TABLES['userindex']} DROP INDEX userindex_uid";
            if (isset($_TABLES['polltopics'])) {
                $_SQLi[] = "ALTER TABLE {$_TABLES['polltopics']} DROP INDEX pollquestions_pid";
            }
            foreach ($_SQLi as $sqli) {
                $rc = DB_query($sqli, 1);
            }
            $_SQLi = array();
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('comment_code', 0, 'select', 4, 21, 17, 1670, TRUE);
            $c->add('comment_edit', 0, 'select', 4, 21, 0, 1680, TRUE);
            $c->add('comment_edittime', 1800, 'text', 4, 21, NULL, 1690, TRUE);
            $c->add('article_comment_close_days', 30, 'text', 4, 21, NULL, 1700, TRUE);
            $c->add('comment_close_rec_stories', 0, 'text', 4, 21, NULL, 1710, TRUE);
            $c->add('image_lib', 'gdlib', 'select', 5, 22, 10, 1450, TRUE);
            $c->add('jhead_enabled', 0, 'select', 5, 22, 0, 1480, TRUE);
            $c->add('path_to_jhead', '', 'text', 5, 22, NULL, 1490, TRUE);
            $c->add('jpegtrans_enabled', 0, 'select', 5, 22, 0, 1500, TRUE);
            $c->add('path_to_jpegtrans', '', 'text', 5, 22, NULL, 1510, TRUE);
            $c->add('hide_adminmenu', TRUE, 'select', 3, 12, 1, 1170, TRUE);
            $c->add('fs_search', NULL, 'fieldset', 0, 6, NULL, 0, TRUE);
            $c->add('search_style', 'google', 'select', 0, 6, 18, 650, TRUE);
            $c->add('search_limits', '10,15,25,30', 'text', 0, 6, NULL, 660, TRUE);
            $c->add('num_search_results', 25, 'text', 0, 6, NULL, 670, TRUE);
            $c->add('search_show_limit', TRUE, 'select', 0, 6, 1, 680, TRUE);
            $c->add('search_show_sort', TRUE, 'select', 0, 6, 1, 690, TRUE);
            $c->add('search_show_num', TRUE, 'select', 0, 6, 1, 700, TRUE);
            $c->add('search_show_type', TRUE, 'select', 0, 6, 1, 710, TRUE);
            $c->add('search_show_user', TRUE, 'select', 0, 6, 1, 720, TRUE);
            $c->add('search_show_hits', TRUE, 'select', 0, 6, 1, 730, TRUE);
            $c->add('search_no_data', '<i>Not available...</i>', 'text', 0, 6, NULL, 740, TRUE);
            $c->add('search_separator', ' &gt; ', 'text', 0, 6, NULL, 750, TRUE);
            $c->add('search_def_keytype', 'phrase', 'select', 0, 6, 19, 760, TRUE);
            $c->add('default_search_order', 'date', 'select', 0, 6, 22, 770, TRUE);
            $c->add('search_use_fulltext', FALSE, 'hidden', 0, 6);
            $c->add('mail_backend', 'mail', 'select', 0, 1, 20, 60, TRUE);
            $c->add('mail_sendmail_path', '', 'text', 0, 1, NULL, 70, TRUE);
            $c->add('mail_sendmail_args', '', 'text', 0, 1, NULL, 80, TRUE);
            $c->add('mail_smtp_host', '', 'text', 0, 1, NULL, 90, TRUE);
            $c->add('mail_smtp_port', '', 'text', 0, 1, NULL, 100, TRUE);
            $c->add('mail_smtp_auth', FALSE, 'select', 0, 1, 0, 110, TRUE);
            $c->add('mail_smtp_username', '', 'text', 0, 1, NULL, 120, TRUE);
            $c->add('mail_smtp_password', '', 'text', 0, 1, NULL, 130, TRUE);
            $c->add('mail_smtp_secure', 'none', 'select', 0, 1, 21, 140, TRUE);
            $c->add('compress_css', TRUE, 'select', 2, 11, 0, 1370, TRUE);
            $c->add('allow_embed_object', TRUE, 'select', 7, 34, 1, 1720, TRUE);
            $c->add('digg_enabled', 1, 'select', 1, 7, 0, 1235, TRUE);
            // now delete the old setting - we don't want it anymore...
            $c->del('mail_settings', 'Core');
            $c->del('use_safe_html', 'Core');
            $c->del('user_html', 'Core');
            $c->del('admin_html', 'Core');
            $c->del('allowed_protocols', 'Core');
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.0',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.0' WHERE name='glfusion'", 1);
            $current_fusion_version = '1.1.0';
            $_SQL = array();
        case '1.1.0':
        case '1.1.1':
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('story_submit_by_perm_only', 0, 'select', 4, 20, 0, 780, TRUE);
            $c->add('use_from_site_mail', 0, 'select', 0, 1, 0, 150, TRUE);
            $c->del('pdf_enabled', 'Core');
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.2',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.2' WHERE name='glfusion'", 1);
            $current_fusion_version = '1.1.2';
        case '1.1.2':
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.2_to_1.1.3.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.1.2_to_1.1.3.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('hidestorydate', 0, 'select', 1, 7, 0, 1205, TRUE);
            $c->add('fs_caching', NULL, 'fieldset', 2, 12, NULL, 0, TRUE);
            $c->add('cache_templates', 1, 'select', 2, 12, 0, 1375, TRUE);
            $c->add('template_comments', FALSE, 'select', 2, 11, 0, 1373, TRUE);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.3',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.3' WHERE name='glfusion'", 1);
            $current_fusion_version = '1.1.3';
        case '1.1.3':
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.3_to_1.1.4.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.1.3_to_1.1.4.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.4',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.4' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.1.4';
        case '1.1.4':
            DB_query("ALTER TABLE {$_TABLES['stories']} DROP INDEX stories_in_transit", 1);
            DB_query("ALTER TABLE {$_TABLES['stories']} DROP COLUMN in_transit", 1);
            DB_query("ALTER TABLE {$_TABLES['userprefs']} ADD search_result_format VARCHAR( 48 ) NOT NULL DEFAULT 'google'", 1);
            DB_query("UPDATE {$_TABLES['conf_values']} SET type='text' WHERE name='mail_smtp_host'", 1);
            DB_query("UPDATE {$_TABLES['conf_values']} SET selectionArray='23' WHERE name='censormode'", 1);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.5',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.5' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('hide_exclude_content', 0, 'select', 4, 16, 0, 295, TRUE);
            $c->add('maintenance_mode', 0, 'select', 0, 0, 0, 520, TRUE);
            $c->del('search_show_limit', 'Core');
            $c->del('search_show_sort', 'Core');
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.4_to_1.1.5.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.1.4_to_1.1.5.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            $current_fusion_version = '1.1.5';
        case '1.1.5':
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.6',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.6' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.1.6';
        case '1.1.6':
            $_SQL = array();
            if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.6_to_1.1.7.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path'] . 'sql/updates/mysql_1.1.6_to_1.1.7.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) {
                echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting');
                exit;
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('rating_enabled', 1, 'select', 1, 7, 24, 1237, TRUE);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.7',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.7' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.1.7';
        case '1.1.7':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('user_reg_fullname', 1, 'select', 4, 19, 25, 980, TRUE);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.8',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.8' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.1.8';
        case '1.1.8':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('article_comment_close_enabled', 0, 'select', 4, 21, 0, 1695, TRUE);
            $session_ip_check = 1;
            if (isset($_SYSTEM['skip_ip_check']) && $_SYSTEM['skip_ip_check'] == 1) {
                $session_ip_check = 0;
            }
            $c->add('session_ip_check', $session_ip_check, 'select', 7, 30, 26, 545, TRUE);
            $c->del('default_search_order', 'Core');
            DB_query("UPDATE {$_TABLES['conf_values']} SET selectionArray = '0' WHERE  name='searchloginrequired' AND group_name='Core'");
            DB_query("ALTER TABLE {$_TABLES['groups']} ADD grp_default tinyint(1) unsigned NOT NULL default '0' AFTER grp_gl_core");
            DB_query("ALTER TABLE {$_TABLES['users']} CHANGE `passwd` `passwd` VARCHAR( 40 ) NOT NULL default ''");
            // clean up group names and assign proper admin setting
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='Bad Behavior2 Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_name='calendar Admin' WHERE grp_name='Calendar Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='calendar Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='filemgmt Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='forum Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_name='links Admin' WHERE grp_name='Links Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='links Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='mediagallery Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_name='polls Admin' WHERE grp_name='Polls Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='polls Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='sitetailor Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_name='staticpages Admin' WHERE grp_name='Static Page Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='staticpages Admin'", 1);
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='spamx Admin'", 1);
            // move multi-language support to its own fieldset
            DB_query("INSERT INTO {$_TABLES['conf_values']} (name,value,type,group_name,default_value,subgroup,selectionArray,sort_order,fieldset) VALUES ('fs_mulitlanguage','N;','fieldset','Core','N;',6,-1,0,41)", 1);
            DB_query("UPDATE {$_TABLES['conf_values']} SET fieldset='41' WHERE name='language_files' AND group_name='Core'", 1);
            DB_query("UPDATE {$_TABLES['conf_values']} SET fieldset='41' WHERE name='languages' AND group_name='Core'", 1);
            // topic sort
            DB_query("ALTER TABLE {$_TABLES['topics']} ADD sort_by TINYINT(1) NOT NULL DEFAULT '0' AFTER archive_flag", 1);
            DB_query("ALTER TABLE {$_TABLES['topics']} ADD sort_dir CHAR( 4 ) NOT NULL DEFAULT 'DESC' AFTER sort_by", 1);
            // new stats.view permission
            DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('stats.view','Allows access to the Stats page.',0)", 1);
            $ft_id = DB_insertId();
            $all_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'All Users'"));
            $loggedin_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Logged-in Users'"));
            $root_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'"));
            if ($_CONF['statsloginrequired'] || $_CONF['loginrequired']) {
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$loggedin_grp_id})", 1);
            } else {
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$all_grp_id})", 1);
            }
            DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$root_grp_id})", 1);
            $c->del('statsloginrequired', 'Core');
            $c->add('registration_type', 0, 'select', 4, 19, 27, 785, TRUE, 'Core');
            DB_query("ALTER TABLE {$_TABLES['users']} ADD act_token VARCHAR(32) NOT NULL DEFAULT '' AFTER pwrequestid", 1);
            DB_query("ALTER TABLE {$_TABLES['users']} ADD act_time DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER act_token", 1);
            $c->del('cookie_ip', 'Core');
            DB_query("ALTER TABLE {$_TABLES['sessions']} DROP PRIMARY KEY", 1);
            DB_query("ALTER TABLE {$_TABLES['sessions']} ADD PRIMARY KEY (md5_sess_id)", 1);
            $c->add('comment_postmode', 'plaintext', 'select', 4, 21, 5, 1693, TRUE);
            $c->add('comment_editor', 0, 'select', 4, 21, 28, 1694, TRUE);
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.2.0',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.2.0' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.2.0';
        case '1.2.0':
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.2.1',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.2.1' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.2.1';
        case '1.2.1':
        case '1.2.2':
        case '1.2.3':
            require_once $_CONF['path'] . 'sql/updates/mysql_1.2.2_to_1.3.0.php';
            list($rc, $errors) = INST_updateDB($_SQL);
            if ($rc === false) {
                return array($rc, $errors);
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            // logo
            $c->add('fs_logo', NULL, 'fieldset', 5, 28, NULL, 0, TRUE);
            $c->add('max_logo_height', 150, 'text', 5, 28, NULL, 1630, TRUE);
            $c->add('max_logo_width', 500, 'text', 5, 28, NULL, 1640, TRUE);
            // whats new cache time
            $c->add('whatsnew_cache_time', 3600, 'text', 3, 15, NULL, 1060, TRUE);
            // add user photo option to whosonline block
            $c->add('whosonline_photo', FALSE, 'select', 3, 14, 0, 930, TRUE);
            // remove old wikitext configuration
            $c->del('wikitext_editor', 'Core');
            // add oauth user_login_method
            $c->del('user_login_method', 'Core');
            // delete microsummary
            $c->del('microsummary_short', 'Core');
            $standard = $_CONF['user_login_method']['standard'] ? true : false;
            $openid = $_CONF['user_login_method']['openid'] ? true : false;
            $thirdparty = $_CONF['user_login_method']['3rdparty'] ? true : false;
            // OAuth configuration settings
            $oauth = false;
            $c->add('user_login_method', array('standard' => $standard, 'openid' => $openid, '3rdparty' => $thirdparty, 'oauth' => $oauth), '@select', 4, 16, 1, 320, TRUE);
            $c->add('facebook_login', 0, 'select', 4, 16, 1, 330, TRUE);
            $c->add('facebook_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 335, TRUE);
            $c->add('facebook_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 340, TRUE);
            $c->add('linkedin_login', 0, 'select', 4, 16, 1, 345, TRUE);
            $c->add('linkedin_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 350, TRUE);
            $c->add('linkedin_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 355, TRUE);
            $c->add('twitter_login', 0, 'select', 4, 16, 1, 360, TRUE);
            $c->add('twitter_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 365, TRUE);
            $c->add('twitter_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 370, TRUE);
            $c->add('google_login', 0, 'select', 4, 16, 1, 375, TRUE);
            $c->add('google_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 380, TRUE);
            $c->add('google_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 385, TRUE);
            $c->add('microsoft_login', 0, 'select', 4, 16, 1, 390, TRUE);
            $c->add('microsoft_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 395, TRUE);
            $c->add('microsoft_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 400, TRUE);
            // date / time format changes
            $c->add('date', 'l, F d Y @ h:i A T', 'text', 6, 29, NULL, 370, TRUE);
            $c->add('daytime', 'm/d h:iA', 'text', 6, 29, NULL, 380, TRUE);
            $c->add('shortdate', 'm/d/y', 'text', 6, 29, NULL, 390, TRUE);
            $c->add('dateonly', 'd-M', 'text', 6, 29, NULL, 400, TRUE);
            $c->add('timeonly', 'H:iA', 'text', 6, 29, NULL, 410, TRUE);
            // hide what's new if empty
            $c->add('hideemptyblock', 0, 'select', 3, 15, 0, 1045, TRUE);
            // update check
            $c->add('fs_update', NULL, 'fieldset', 0, 7, NULL, 0, TRUE);
            $c->add('update_check_interval', '86400', 'select', 0, 7, 29, 765, TRUE);
            $c->add('send_site_data', TRUE, 'select', 0, 7, 1, 770, TRUE);
            // rating
            $c->add('fs_rating', NULL, 'fieldset', 4, 7, NULL, 0, TRUE);
            $c->add('rating_speedlimit', 15, 'text', 4, 7, NULL, 10, TRUE);
            // add new logo.admin permission
            $result = DB_query("SELECT * FROM {$_TABLES['features']} WHERE ft_name='logo.admin'");
            if (DB_numRows($result) == 0) {
                DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('logo.admin','Ability to modify site logo',1)", 1);
                $ft_id = DB_insertId();
                $grp_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'");
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$grp_id})", 1);
            }
            // add new menu.admin permission
            $result = DB_query("SELECT * FROM {$_TABLES['features']} WHERE ft_name='menu.admin'");
            if (DB_numRows($result) == 0) {
                DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('menu.admin','Ability to create/edit site menus',1)", 1);
                $ft_id = DB_insertId();
                $grp_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'");
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$grp_id})", 1);
            }
            // add new autotag features
            $autotag_admin_ft_id = 0;
            $autotag_php_ft_id = 0;
            $autotag_group_id = 0;
            $tmp_admin_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'autotag.admin'");
            if (empty($tmp_admin_ft_id)) {
                DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('autotag.admin','Ability to create / edit autotags',1)", 1);
                $autotag_admin_ft_id = DB_insertId();
            }
            $tmp_php_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'autotag.PHP'");
            if (empty($tmp_php_ft_id)) {
                DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('autotag.PHP','Ability to create / edit autotags utilizing PHP functions',1)", 1);
                $autotag_php_ft_id = DB_insertId();
            }
            // now check for the group
            $result = DB_query("SELECT * FROM {$_TABLES['groups']} WHERE grp_name='Autotag Admin'");
            if (DB_numRows($result) == 0) {
                DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core, grp_default) VALUES ('Autotag Admin','Has full access to create and modify autotags',1,0)");
                $autotag_group_id = DB_insertId();
            }
            if ($autotag_admin_ft_id != 0 && $autotag_group_id != 0) {
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $autotag_admin_ft_id . "," . $autotag_group_id . ")");
            }
            if ($autotag_php_ft_id != 0 && $autotag_group_id != 0) {
                DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $autotag_php_ft_id . "," . $autotag_group_id . ")");
            }
            if ($autotag_group_id != 0) {
                DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id,ug_grp_id) VALUES (" . $autotag_group_id . ",1)");
            }
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.3.0',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='1.3.0' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            $current_fusion_version = '1.3.0';
        case '1.3.0':
            $current_fusion_version = '1.3.1';
        case '1.3.1':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $current_fusion_version = '1.3.2';
        case '1.3.2':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            // remove menu_elements - no longer used
            $c->del('menu_elements', 'Core');
            $c->del('mailstory_postmode', 'Core');
            $c->del('comment_editor', 'Core');
            $c->del('advanced_editor', 'Core');
            if (!isset($_CONF['mailuser_postmode'])) {
                $c->add('mailuser_postmode', 'html', 'select', 4, 5, 5, 43, TRUE);
            }
            // set the initial set of html elements
            if (!isset($_CONF['htmlfilter_comment'])) {
                $c->add('htmlfilter_default', 'p,b,a,i,strong,em,br', 'text', 7, 5, NULL, 30, true);
                $c->add('htmlfilter_comment', 'p,b,a,i,strong,em,br,tt,hr,li,ol,ul,code,pre', 'text', 7, 5, NULL, 35, TRUE);
                $c->add('htmlfilter_story', 'div[class],h1,h2,h3,pre,br,p[style],b[style],s,strong[style],i[style],em[style],u[style],strike,a[style|href|title|target],ol[style|class],ul[style|class],li[style|class],hr[style],blockquote[style],img[style|alt|title|width|height|src|align],table[style|width|bgcolor|align|cellspacing|cellpadding|border],tr[style],td[style],th[style],tbody,thead,caption,col,colgroup,span[style|class],sup,sub', 'text', 7, 5, NULL, 40, TRUE);
                $c->add('htmlfilter_root', 'div[style|class],span[style|class],table,tr,td,th', 'text', 7, 5, NULL, 50, TRUE);
            }
            $sql = "REPLACE INTO {$_TABLES['autotags']} (tag, description, is_enabled, is_function, replacement) VALUES ('youtube', 'Embed Youtube videos into content. Usage:[youtube:ID height:px width:px align:left/right/center pad:px]', 1, 1, NULL)";
            DB_query($sql, 1);
            $current_fusion_version = '1.4.0';
        case '1.4.0':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('github_login', 0, 'select', 4, 1, 1, 271, TRUE);
            $c->add('github_consumer_key', 'not configured yet', 'text', 4, 1, NULL, 272, TRUE);
            $c->add('github_consumer_secret', 'not configured yet', 'text', 4, 1, NULL, 273, TRUE);
            $current_fusion_version = '1.4.1';
        case '1.4.1':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $current_fusion_version = '1.4.2';
        case '1.4.2':
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $c->add('min_username_length', '4', 'text', 4, 4, NULL, 60, TRUE);
            $current_fusion_version = '1.4.3';
        case '1.4.3':
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `alternate_tid` VARCHAR(20) NULL DEFAULT NULL AFTER `tid`, ADD INDEX `alternate_topic` (`alternate_tid`) ;";
            $_SQL[] = "ALTER TABLE {$_TABLES['tokens']} CHANGE `urlfor` `urlfor` VARCHAR( 1024 ) NOT NULL";
            $_SQL[] = "ALTER TABLE {$_TABLES['comments']} CHANGE  `ipaddress`  `ipaddress` VARCHAR( 45 ) NOT NULL DEFAULT  ''";
            $_SQL[] = "ALTER TABLE {$_TABLES['rating_votes']} CHANGE  `ip_address`  `ip_address` VARCHAR( 45 ) NOT NULL";
            $_SQL[] = "ALTER TABLE {$_TABLES['sessions']} CHANGE  `remote_ip`  `remote_ip` VARCHAR( 45 ) NOT NULL DEFAULT  ''";
            $_SQL[] = "ALTER TABLE {$_TABLES['trackback']}  `ipaddress`  `ipaddress` VARCHAR( 45 ) NOT NULL DEFAULT  ''";
            $_SQL[] = "ALTER TABLE {$_TABLES['users']} CHANGE  `remote_ip`  `remote_ip` VARCHAR( 45 ) NOT NULL DEFAULT  ''";
            $_SQL[] = "ALTER TABLE {$_TABLES['topics']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT '';";
            $_SQL[] = "ALTER TABLE {$_TABLES['topics']} CHANGE `topic` `topic` VARCHAR(128) NULL DEFAULT NULL;";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'General';";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `alternate_tid` `alternate_tid` VARCHAR(128) NULL DEFAULT NULL;";
            $_SQL[] = "ALTER TABLE {$_TABLES['blocks']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'All';";
            $_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'General';";
            foreach ($_SQL as $sql) {
                DB_query($sql, 1);
            }
            $result = DB_query("SELECT * FROM {$_TABLES['autotags']} WHERE tag='uikitlogin'");
            if (DB_numRows($result) < 1) {
                $sql = "INSERT INTO {$_TABLES['autotags']} (`tag`, `description`, `is_enabled`, `is_function`, `replacement`) VALUES ('uikitlogin', 'UIKit Login Widget', '1', '1', NULL);";
                DB_query($sql, 1);
            }
            require_once $_CONF['path_system'] . 'classes/config.class.php';
            $c = config::get_instance();
            $current_fusion_version = '1.5.0';
        case '1.5.0':
            $_SQL[] = "ALTER TABLE {$_TABLES['article_images']} CHANGE `ai_sid` `ai_sid` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['comments']} CHANGE `sid` `sid` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `sid` `sid` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} CHANGE `sid` `sid` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['syndication']} CHANGE `topic` `topic` VARCHAR(128);";
            $_SQL[] = "ALTER TABLE {$_TABLES['trackback']} CHANGE `sid` `sid` VARCHAR(128);";
            foreach ($_SQL as $sql) {
                DB_query($sql, 1);
            }
            $current_fusion_version = '1.5.1';
        case '1.5.1':
            $current_fusion_version = '1.5.2';
        default:
            DB_query("INSERT INTO {$_TABLES['vars']} SET value='" . $current_fusion_version . "',name='glfusion'", 1);
            DB_query("UPDATE {$_TABLES['vars']} SET value='" . $current_fusion_version . "' WHERE name='glfusion'", 1);
            DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1);
            break;
    }
    DB_query("ALTER TABLE {$_TABLES['userprefs']} ADD search_result_format VARCHAR( 48 ) NOT NULL DEFAULT 'google'", 1);
    // delete the security check flag on every update to force the user
    // to run admin/sectest.php again
    DB_delete($_TABLES['vars'], 'name', 'security_check');
    INST_resyncConfig();
    return array($rc, $errors);
}
コード例 #4
0
ファイル: lib-upgrade.php プロジェクト: hostellerie/nexpro
/**
 * Perform database upgrades
 *
 * @param   string  $current_gl_version Current Geeklog version
 * @return  boolean                     True if successful
 *
 */
function INST_doDatabaseUpgrades($current_gl_version)
{
    global $_TABLES, $_CONF, $_SP_CONF, $_DB, $_DB_dbms, $_DB_table_prefix, $dbconfig_path, $siteconfig_path, $html_path;
    $_DB->setDisplayError(true);
    // Because the upgrade sql syntax can vary from dbms-to-dbms we are
    // leaving that up to each Geeklog database driver
    $done = false;
    $progress = '';
    while ($done == false) {
        switch ($current_gl_version) {
            case '1.2.5-1':
                // Get DMBS-specific update sql
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.2.5-1_to_1.3.php';
                INST_updateDB($_SQL);
                // OK, now we need to add all users except anonymous to the All Users group and Logged in users group
                // I can hard-code these group numbers because the group table was JUST created with these numbers
                $result = DB_query("SELECT uid FROM {$_TABLES['users']} WHERE uid <> 1");
                $nrows = DB_numRows($result);
                for ($i = 1; $i <= $nrows; $i++) {
                    $U = DB_fetchArray($result);
                    DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES (2, {$U['uid']}, NULL)");
                    DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES (13, {$U['uid']}, NULL)");
                }
                // Now take care of any orphans off the user table...and let me curse MySQL lack for supporting foreign
                // keys at this time ;-)
                $result = DB_query("SELECT MAX(uid) FROM {$_TABLES['users']}");
                $ITEM = DB_fetchArray($result);
                $max_uid = $ITEM[0];
                if (!empty($max_uid) and $max_uid != 0) {
                    DB_query("DELETE FROM {$_TABLES['userindex']} WHERE uid > {$max_uid}");
                    DB_query("DELETE FROM {$_TABLES['userinfo']} WHERE uid > {$max_uid}");
                    DB_query("DELETE FROM {$_TABLES['userprefs']} WHERE uid > {$max_uid}");
                    DB_query("DELETE FROM {$_TABLES['usercomment']} WHERE uid > {$max_uid}");
                }
                $current_gl_version = '1.3';
                $_SQL = '';
                break;
            case '1.3':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3_to_1.3.1.php';
                INST_updateDB($_SQL);
                $current_gl_version = '1.3.1';
                $_SQL = '';
                break;
            case '1.3.1':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.1_to_1.3.2.php';
                INST_updateDB($_SQL);
                $current_gl_version = '1.3.2-1';
                $_SQL = '';
                break;
            case '1.3.2':
            case '1.3.2-1':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.2-1_to_1.3.3.php';
                INST_updateDB($_SQL);
                // Now we need to switch how user blocks are stored.  Right now we only store the blocks the
                // user wants.  This will switch it to store the ones they don't want which allows us to add
                // new blocks and ensure they are shown to the user.
                $result = DB_query("SELECT {$_TABLES['users']}.uid,boxes FROM {$_TABLES['users']},{$_TABLES['userindex']} WHERE boxes IS NOT NULL AND boxes <> '' AND {$_TABLES['users']}.uid = {$_TABLES['userindex']}.uid");
                $nrows = DB_numRows($result);
                for ($i = 1; $i <= $nrows; $i++) {
                    $row = DB_fetchArray($result);
                    $ublocks = str_replace(' ', ',', $row['boxes']);
                    $result2 = DB_query("SELECT bid,name FROM {$_TABLES['blocks']} WHERE bid NOT IN ({$ublocks})");
                    $newblocks = '';
                    for ($x = 1; $x <= DB_numRows($result2); $x++) {
                        $curblock = DB_fetchArray($result2);
                        if ($curblock['name'] != 'user_block' and $curblock['name'] != 'admin_block' and $curblock['name'] != 'section_block') {
                            $newblocks .= $curblock['bid'];
                            if ($x != DB_numRows($result2)) {
                                $newblocks .= ' ';
                            }
                        }
                    }
                    DB_query("UPDATE {$_TABLES['userindex']} SET boxes = '{$newblocks}' WHERE uid = {$row['uid']}");
                }
                $current_gl_version = '1.3.3';
                $_SQL = '';
                break;
            case '1.3.3':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.3_to_1.3.4.php';
                INST_updateDB($_SQL);
                $current_gl_version = '1.3.4';
                $_SQL = '';
                break;
            case '1.3.4':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.4_to_1.3.5.php';
                INST_updateDB($_SQL);
                $result = DB_query("SELECT ft_id FROM {$_TABLES['features']} WHERE ft_name = 'user.mail'");
                $row = DB_fetchArray($result);
                $mail_ft = $row['ft_id'];
                $result = DB_query("SELECT grp_id FROM {$_TABLES['groups']} WHERE grp_name = 'Mail Admin'");
                $row = DB_fetchArray($result);
                $group_id = $row['grp_id'];
                DB_query("INSERT INTO {$_TABLES['access']} (acc_grp_id, acc_ft_id) VALUES ({$group_id}, {$mail_ft})");
                $current_gl_version = '1.3.5';
                $_SQL = '';
                break;
            case '1.3.5':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.5_to_1.3.6.php';
                INST_updateDB($_SQL);
                if (!empty($_DB_table_prefix)) {
                    DB_query("RENAME TABLE staticpage TO {$_TABLES['staticpage']}");
                }
                $current_gl_version = '1.3.6';
                $_SQL = '';
                break;
            case '1.3.6':
                // fix wrong permissions value
                DB_query("UPDATE {$_TABLES['topics']} SET perm_anon = 2 WHERE perm_anon = 3");
                // check for existence of 'date' field in gl_links table
                DB_query("SELECT date FROM {$_TABLES['links']}", 1);
                $dterr = DB_error();
                if (strpos($dterr, 'date') > 0) {
                    DB_query("ALTER TABLE {$_TABLES['links']} ADD date datetime default NULL");
                }
                // Fix primary key so that more than one user can add an event
                // to his/her personal calendar.
                DB_query("ALTER TABLE {$_TABLES['personal_events']} DROP PRIMARY KEY, ADD PRIMARY KEY (eid,uid)");
                $current_gl_version = '1.3.7';
                $_SQL = '';
                break;
            case '1.3.7':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.7_to_1.3.8.php';
                INST_updateDB($_SQL);
                // upgrade Static Pages plugin
                $spversion = get_SP_ver();
                if ($spversion == 1) {
                    // original version
                    DB_query("ALTER TABLE {$_TABLES['staticpage']} " . "ADD COLUMN group_id mediumint(8) unsigned DEFAULT '1'," . "ADD COLUMN owner_id mediumint(8) unsigned DEFAULT '1'," . "ADD COLUMN perm_owner tinyint(1) unsigned DEFAULT '3'," . "ADD COLUMN perm_group tinyint(1) unsigned DEFAULT '2'," . "ADD COLUMN perm_members tinyint(1) unsigned DEFAULT '2'," . "ADD COLUMN perm_anon tinyint(1) unsigned DEFAULT '2'," . "ADD COLUMN sp_php tinyint(1) unsigned DEFAULT '0'," . "ADD COLUMN sp_nf tinyint(1) unsigned DEFAULT '0'," . "ADD COLUMN sp_centerblock tinyint(1) unsigned NOT NULL default '0'," . "ADD COLUMN sp_tid varchar(20) NOT NULL default 'none'," . "ADD COLUMN sp_where tinyint(1) unsigned NOT NULL default '1'");
                    DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) VALUES ('staticpages.PHP','Ability to use PHP in static pages')");
                    $php_id = DB_insertId();
                    $group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Static Page Admin'");
                    DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$php_id}, {$group_id})");
                } elseif ($spversion == 2) {
                    // extended version by Phill or Tom
                    DB_query("ALTER TABLE {$_TABLES['staticpage']} " . "DROP COLUMN sp_pos," . "DROP COLUMN sp_search_keywords," . "ADD COLUMN sp_nf tinyint(1) unsigned DEFAULT '0'," . "ADD COLUMN sp_centerblock tinyint(1) unsigned NOT NULL default '0'," . "ADD COLUMN sp_tid varchar(20) NOT NULL default 'none'," . "ADD COLUMN sp_where tinyint(1) unsigned NOT NULL default '1'");
                }
                if ($spversion > 0) {
                    // update plugin version number
                    DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.3', pi_gl_version = '1.3.8' WHERE pi_name = 'staticpages'");
                    // remove Static Pages 'lock' flag
                    DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = 'staticpages'");
                    // remove Static Pages Admin group id
                    DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = 'sp_group_id'");
                    if ($spversion == 1) {
                        $result = DB_query("SELECT DISTINCT sp_uid FROM {$_TABLES['staticpage']}");
                        $authors = DB_numRows($result);
                        for ($i = 0; $i < $authors; $i++) {
                            $A = DB_fetchArray($result);
                            DB_query("UPDATE {$_TABLES['staticpage']} SET owner_id = '{$A['sp_uid']}' WHERE sp_uid = '{$A['sp_uid']}'");
                        }
                    }
                    $result = DB_query("SELECT sp_label FROM {$_TABLES['staticpage']} WHERE sp_title = 'Frontpage'");
                    if (DB_numRows($result) > 0) {
                        $A = DB_fetchArray($result);
                        if ($A['sp_label'] == 'nonews') {
                            DB_query("UPDATE {$_TABLES['staticpage']} SET sp_centerblock = 1, sp_where = 0 WHERE sp_title = 'Frontpage'");
                        } else {
                            if (!empty($A['sp_label'])) {
                                DB_query("UPDATE {$_TABLES['staticpage']} SET sp_centerblock = 1, sp_title = '{$A['sp_label']}' WHERE sp_title = 'Frontpage'");
                            } else {
                                DB_query("UPDATE {$_TABLES['staticpage']} SET sp_centerblock = 1 WHERE sp_title = 'Frontpage'");
                            }
                        }
                    }
                }
                $current_gl_version = '1.3.8';
                $_SQL = '';
                break;
            case '1.3.8':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.8_to_1.3.9.php';
                INST_updateDB($_SQL);
                $pos = strrpos($_CONF['rdf_file'], '/');
                $filename = substr($_CONF['rdf_file'], $pos + 1);
                $sitename = addslashes($_CONF['site_name']);
                $siteslogan = addslashes($_CONF['site_slogan']);
                DB_query("INSERT INTO {$_TABLES['syndication']} (title, description, limits, content_length, filename, charset, language, is_enabled, updated, update_info) VALUES ('{$sitename}', '{$siteslogan}', '{$_CONF['rdf_limit']}', {$_CONF['rdf_storytext']}, '{$filename}', '{$_CONF['default_charset']}', '{$_CONF['rdf_language']}', {$_CONF['backend']}, '0000-00-00 00:00:00', NULL)");
                // upgrade static pages plugin
                $spversion = get_SP_ver();
                if ($spversion > 0) {
                    if ($spversion < 4) {
                        if (!isset($_SP_CONF['in_block'])) {
                            $_SP_CONF['in_block'] = 1;
                        } else {
                            if ($_SP_CONF['in_block'] > 1) {
                                $_SP_CONF['in_block'] = 1;
                            } else {
                                if ($_SP_CONF['in_block'] < 0) {
                                    $_SP_CONF['in_block'] = 0;
                                }
                            }
                        }
                        DB_query("ALTER TABLE {$_TABLES['staticpage']} ADD COLUMN sp_inblock tinyint(1) unsigned DEFAULT '{$_SP_CONF['in_block']}'");
                    }
                    DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.4', pi_gl_version = '1.3.9' WHERE pi_name = 'staticpages'");
                }
                // recreate 'date' field for old links
                $result = DB_query("SELECT lid FROM {$_TABLES['links']} WHERE date IS NULL");
                $num = DB_numRows($result);
                if ($num > 0) {
                    for ($i = 0; $i < $num; $i++) {
                        $A = DB_fetchArray($result);
                        $myyear = substr($A['lid'], 0, 4);
                        $mymonth = substr($A['lid'], 4, 2);
                        $myday = substr($A['lid'], 6, 2);
                        $myhour = substr($A['lid'], 8, 2);
                        $mymin = substr($A['lid'], 10, 2);
                        $mysec = substr($A['lid'], 12, 2);
                        $mtime = mktime($myhour, $mymin, $mysec, $mymonth, $myday, $myyear);
                        $date = date("Y-m-d H:i:s", $mtime);
                        DB_query("UPDATE {$_TABLES['links']} SET date = '{$date}' WHERE lid = '{$A['lid']}'");
                    }
                }
                // remove unused entries left over from deleted groups
                $result = DB_query("SELECT grp_id FROM {$_TABLES['groups']}");
                $num = DB_numRows($result);
                $groups = array();
                for ($i = 0; $i < $num; $i++) {
                    $A = DB_fetchArray($result);
                    $groups[] = $A['grp_id'];
                }
                $grouplist = '(' . implode(',', $groups) . ')';
                DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE (ug_main_grp_id NOT IN {$grouplist}) OR (ug_grp_id NOT IN {$grouplist})");
                $current_gl_version = '1.3.9';
                $_SQL = '';
                break;
            case '1.3.9':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.9_to_1.3.10.php';
                INST_updateDB($_SQL);
                commentsToPreorderTree();
                $result = DB_query("SELECT sid,introtext,bodytext FROM {$_TABLES['stories']}");
                $numStories = DB_numRows($result);
                for ($i = 0; $i < $numStories; $i++) {
                    $A = DB_fetchArray($result);
                    $related = addslashes(implode("\n", UPDATE_extractLinks($A['introtext'] . ' ' . $A['bodytext'])));
                    if (empty($related)) {
                        DB_query("UPDATE {$_TABLES['stories']} SET related = NULL WHERE sid = '{$A['sid']}'");
                    } else {
                        DB_query("UPDATE {$_TABLES['stories']} SET related = '{$related}' WHERE sid = '{$A['sid']}'");
                    }
                }
                $spversion = get_SP_ver();
                if ($spversion > 0) {
                    // no database changes this time, but set new version number
                    DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.4.1', pi_gl_version = '1.3.10' WHERE pi_name = 'staticpages'");
                }
                // install SpamX plugin
                // (also handles updates from version 1.0)
                install_spamx_plugin();
                $current_gl_version = '1.3.10';
                $_SQL = '';
                break;
            case '1.3.10':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.10_to_1.3.11.php';
                INST_updateDB($_SQL);
                $current_gl_version = '1.3.11';
                $_SQL = '';
                break;
            case '1.3.11':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.11_to_1.4.0.php';
                INST_updateDB($_SQL);
                upgrade_addFeature();
                upgrade_uniqueGroupNames();
                $current_gl_version = '1.4.0';
                $_SQL = '';
                break;
            case '1.4.0':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.4.0_to_1.4.1.php';
                INST_updateDB($_SQL);
                upgrade_addSyndicationFeature();
                upgrade_ensureLastScheduledRunFlag();
                upgrade_plugins_141();
                $current_gl_version = '1.4.1';
                $_SQL = '';
                break;
            case '1.4.1':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.4.1_to_1.5.0.php';
                INST_updateDB($_SQL);
                upgrade_addWebservicesFeature();
                create_ConfValues();
                require_once $_CONF['path_system'] . 'classes/config.class.php';
                $config = config::get_instance();
                if (file_exists($_CONF['path'] . 'config.php')) {
                    // Read the values from config.php and use them to populate conf_values
                    $tmp_path = $_CONF['path'];
                    // We'll need this to remember what the correct path is.
                    // Including config.php will overwrite all our $_CONF values.
                    require $tmp_path . 'config.php';
                    // Load some important values from config.php into conf_values
                    foreach ($_CONF as $key => $val) {
                        $config->set($key, $val);
                    }
                    if (!INST_setDefaultCharset($siteconfig_path, $_CONF['default_charset'])) {
                        exit($LANG_INSTALL[26] . ' ' . $siteconfig_path . $LANG_INSTALL[58]);
                    }
                    require $siteconfig_path;
                    require $dbconfig_path;
                }
                // Update the GL configuration with the correct paths.
                $config->set('path_html', $html_path);
                $config->set('path_log', $_CONF['path'] . 'logs/');
                $config->set('path_language', $_CONF['path'] . 'language/');
                $config->set('backup_path', $_CONF['path'] . 'backups/');
                $config->set('path_data', $_CONF['path'] . 'data/');
                $config->set('path_images', $html_path . 'images/');
                $config->set('path_themes', $html_path . 'layout/');
                $config->set('rdf_file', $html_path . 'backend/geeklog.rss');
                $config->set('path_pear', $_CONF['path_system'] . 'pear/');
                if (INST_pluginExists('calendar')) {
                    $check = upgrade_CalendarPlugin();
                    if (!$check) {
                        echo "Error updating the calendar";
                        return false;
                    }
                }
                if (INST_pluginExists('polls')) {
                    $check = upgrade_PollsPlugin();
                    if (!$check) {
                        echo "Error updating the polls";
                        return false;
                    }
                }
                if (INST_pluginExists('staticpages')) {
                    $check = upgrade_StaticpagesPlugin();
                    if (!$check) {
                        echo "Error updating the staticpages";
                        return false;
                    }
                }
                if (INST_pluginExists('links')) {
                    $check = upgrade_LinksPlugin();
                    if (!$check) {
                        echo "Error updating the links";
                        return false;
                    }
                }
                if (INST_pluginExists('spamx')) {
                    $check = upgrade_SpamXPlugin();
                    if (!$check) {
                        echo "Error updating the spamx";
                        return false;
                    }
                }
                $current_gl_version = '1.5.0';
                $_SQL = '';
                break;
            case '1.5.0':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.5.0_to_1.5.1.php';
                INST_updateDB($_SQL);
                $current_gl_version = '1.5.1';
                $_SQL = '';
                break;
            case '1.5.1':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.5.1_to_1.5.2.php';
                INST_updateDB($_SQL);
                $current_gl_version = '1.5.2';
                $_SQL = '';
                break;
            case '1.5.2':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.5.2_to_1.6.0.php';
                INST_updateDB($_SQL);
                update_ConfValues();
                upgrade_addNewPermissions();
                upgrade_addIsoFormat();
                INST_fixOptionalConfig();
                $current_gl_version = '1.6.0';
                $_SQL = '';
                break;
            case '1.6.0':
                require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.6.0_to_1.6.1.php';
                INST_updateDB($_SQL);
                update_ConfValuesFor161();
                $current_gl_version = '1.6.1';
                $_SQL = '';
                break;
            default:
                $done = true;
        }
    }
    INST_setVersion($siteconfig_path);
    // delete the security check flag on every update to force the user
    // to run admin/sectest.php again
    DB_delete($_TABLES['vars'], 'name', 'security_check');
    return true;
}