Esempio n. 1
0
function saveContent($option, $task)
{
    global $mainframe;
    $row =& JTable::getInstance('saasycontent', 'Table');
    if (!$row->bind(JRequest::get('post'))) {
        _displayError($row);
    }
    $row->content = JRequest::getVar('content', '', 'post', 'string', JREQUEST_ALLOWRAW);
    if (!$row->store()) {
        _displayError($row);
    }
    switch ($task) {
        case 'apply':
            $msg = 'Changes to Content Saved';
            $link = "index.php?option={$option}&task=edit&cid[]={$row->id}";
            break;
        case 'save':
        default:
            $msg = 'Content Saved';
            $link = "index.php?option={$option}";
            break;
    }
    $mainframe->redirect($link, $msg);
}
Esempio n. 2
0
/**
 * 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);
}
Esempio n. 3
0
/**
 * 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);
}
Esempio n. 4
0
/**
 * Calls all bundled plugin upgrade routines
 *
 * @return  string          HTML or redirects to success page
 *
 */
function INST_doPluginUpgrade()
{
    global $_GLFUSION, $_CONF, $_TABLES, $LANG_INSTALL;
    $language = $_GLFUSION['language'];
    $upgradeError = '';
    $error = '';
    INST_checkPlugins();
    $rc = INST_pluginAutoUpgrade('calendar');
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'Calendar');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('links');
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'Links');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('polls');
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'Polls');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('spamx', 1);
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'Spamx');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('staticpages', 1);
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'Static Pages');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('captcha', 1);
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'CAPTCHA');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('bad_behavior2', 1);
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'Bad Behavior2');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('filemgmt');
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'FileMgmt');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('forum');
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'Forum');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('mediagallery');
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'Media Gallery');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('commentfeeds', 1);
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'Comment Feeds');
        $upgradeError = 1;
    }
    $rc = INST_pluginAutoUpgrade('ckeditor', 1);
    if ($rc == false) {
        $error .= sprintf($LANG_INSTALL['plugin_upgrade_error'], 'CKEditor');
        $upgradeError = 1;
    }
    $stdPlugins = array('ckeditor', 'staticpages', 'spamx', 'links', 'polls', 'calendar', 'captcha', 'bad_behavior2', 'forum', 'mediagallery', 'filemgmt', 'commentfeeds');
    foreach ($stdPlugins as $pi_name) {
        DB_query("UPDATE {$_TABLES['plugins']} SET pi_gl_version='" . GVERSION . "', pi_homepage='http://www.glfusion.org' WHERE pi_name='" . $pi_name . "'", 1);
    }
    INST_clearCache();
    // ************* TEST CODE - REMOVE *****
    // $upgradeError = 1;
    // $error = 'Problem 1<br>Problem 2<br>';
    // **************************************
    if ($upgradeError) {
        return _displayError(PLUGIN_UPGRADE_ERROR, 'done', $error);
    }
    header('Location: success.php?type=upgrade&language=' . $language);
}