Exemple #1
0
/**
 * Installer engine
 *
 * The guts of the installation and upgrade package.
 *
 * @param   string  $install_type   'install' or 'upgrade'
 * @param   int     $install_step   1 - 4
 */
function INST_installEngine($install_type, $install_step)
{
    global $_CONF, $_TABLES, $LANG_INSTALL, $LANG_CHARSET, $_DB, $_DB_dbms, $_DB_table_prefix, $_URL, $gl_path, $html_path, $dbconfig_path, $siteconfig_path, $display, $language, $form_label_dir, $use_innodb;
    switch ($install_step) {
        /**
         * Page 1 - Enter Geeklog config information
         */
        case 1:
            require_once $dbconfig_path;
            // Get the current DB info
            if ($install_type == 'upgrade') {
                $v = INST_checkPost150Upgrade($dbconfig_path, $siteconfig_path);
                // will skip to step 3 if possible, otherwise return here
                if ($v == VERSION) {
                    // looks like we're already up to date
                    $display .= '<h2>' . $LANG_INSTALL[74] . '</h2>' . LB . '<p>' . $LANG_INSTALL[75] . '</p>';
                    return;
                }
            }
            $display .= '<h1 class="heading">' . $LANG_INSTALL[101] . ' ' . htmlspecialchars($_REQUEST['display_step']) . ' - ' . $LANG_INSTALL[102] . '</h1>' . LB;
            // Set all the form values either with their defaults or with received POST data.
            // The only instance where you'd get POST data would be if the user has to
            // go back because they entered incorrect database information.
            $site_name = isset($_POST['site_name']) ? str_replace('\\', '', $_POST['site_name']) : $LANG_INSTALL[29];
            $site_slogan = isset($_POST['site_slogan']) ? str_replace('\\', '', $_POST['site_slogan']) : $LANG_INSTALL[30];
            $mysql_innodb_selected = '';
            $mysql_selected = '';
            $mssql_selected = '';
            if (isset($_POST['db_type'])) {
                switch ($_POST['db_type']) {
                    case 'mysql-innodb':
                        $mysql_innodb_selected = ' selected="selected"';
                        break;
                    case 'mssql':
                        $mssql_selected = ' selected="selected"';
                        break;
                    default:
                        $mysql_selected = ' selected="selected"';
                        break;
                }
            } else {
                switch ($_DB_dbms) {
                    case 'mssql':
                        $mssql_selected = ' selected="selected"';
                        break;
                    default:
                        $mysql_selected = ' selected="selected"';
                        break;
                }
            }
            if ($_DB_host != 'localhost' || $_DB_name != 'geeklog' || $_DB_user != 'username' || $_DB_pass != 'password') {
                // only display those if they all have their default values
                $_DB_host = '';
                $_DB_name = '';
                $_DB_user = '';
                $_DB_pass = '';
            }
            $db_host = isset($_POST['db_host']) ? $_POST['db_host'] : ($_DB_host != 'localhost' ? '' : $_DB_host);
            $db_name = isset($_POST['db_name']) ? $_POST['db_name'] : ($_DB_name != 'geeklog' ? '' : $_DB_name);
            $db_user = isset($_POST['db_user']) ? $_POST['db_user'] : ($_DB_user != 'username' ? '' : $_DB_user);
            $db_pass = isset($_POST['db_pass']) ? $_POST['db_pass'] : '';
            $db_prefix = isset($_POST['db_prefix']) ? $_POST['db_prefix'] : $_DB_table_prefix;
            $site_url = isset($_POST['site_url']) ? $_POST['site_url'] : INST_getSiteUrl();
            $site_admin_url = isset($_POST['site_admin_url']) ? $_POST['site_admin_url'] : INST_getSiteAdminUrl();
            $host_name = explode(':', $_SERVER['HTTP_HOST']);
            $host_name = $host_name[0];
            if (empty($_CONF['site_mail'])) {
                $_CONF['site_mail'] = '*****@*****.**';
            }
            $site_mail = isset($_POST['site_mail']) ? $_POST['site_mail'] : ($_CONF['site_mail'] != '*****@*****.**' ? $_CONF['site_mail'] : 'admin@' . $host_name);
            if (empty($_CONF['noreply_mail'])) {
                $_CONF['noreply_mail'] = '*****@*****.**';
            }
            $noreply_mail = isset($_POST['noreply_mail']) ? $_POST['noreply_mail'] : ($_CONF['noreply_mail'] != '*****@*****.**' ? $_CONF['noreply_mail'] : 'noreply@' . $host_name);
            if (isset($_POST['utf8']) && $_POST['utf8'] == 'on') {
                $utf8 = true;
            } else {
                $utf8 = false;
                if (strcasecmp($LANG_CHARSET, 'utf-8') == 0) {
                    $utf8 = true;
                }
            }
            if ($install_type == 'install') {
                $buttontext = $LANG_INSTALL[50];
            } else {
                $buttontext = $LANG_INSTALL[25];
            }
            $display .= '<h2>' . $LANG_INSTALL[31] . '</h2>
            <form action="index.php" method="post" name="install">
            <input type="hidden" name="mode" value="' . htmlspecialchars($install_type) . '"' . XHTML . '>
            <input type="hidden" name="step" value="2"' . XHTML . '>
            <input type="hidden" name="display_step" value="' . htmlspecialchars($_REQUEST['display_step']) . '"' . XHTML . '>
            <input type="hidden" name="language" value="' . $language . '"' . XHTML . '>
            <input type="hidden" name="dbconfig_path" value="' . htmlspecialchars($dbconfig_path) . '"' . XHTML . '>

            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[32] . ' ' . INST_helpLink('site_name') . '</label> <input type="text" name="site_name" value="' . htmlspecialchars($site_name) . '" size="40"' . XHTML . '></p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[33] . ' ' . INST_helpLink('site_slogan') . '</label> <input type="text" name="site_slogan" value="' . htmlspecialchars($site_slogan) . '" size="40"' . XHTML . '></p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[34] . ' ' . INST_helpLink('db_type') . '</label> <select name="db_type">
                <option value="mysql"' . $mysql_selected . '>' . $LANG_INSTALL[35] . '</option>
                ' . ($install_type == 'install' ? '<option value="mysql-innodb"' . $mysql_innodb_selected . '>' . $LANG_INSTALL[36] . '</option>' : '') . '
                <option value="mssql"' . $mssql_selected . '>' . $LANG_INSTALL[37] . '</option></select> ' . '</p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[39] . ' ' . INST_helpLink('db_host') . '</label> <input type="text" name="db_host" value="' . htmlspecialchars($db_host) . '" size="20"' . XHTML . '></p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[40] . ' ' . INST_helpLink('db_name') . '</label> <input type="text" name="db_name" value="' . htmlspecialchars($db_name) . '" size="20"' . XHTML . '></p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[41] . ' ' . INST_helpLink('db_user') . '</label> <input type="text" name="db_user" value="' . htmlspecialchars($db_user) . '" size="20"' . XHTML . '></p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[42] . ' ' . INST_helpLink('db_pass') . '</label> <input type="password" name="db_pass" value="' . $db_pass . '" size="20"' . XHTML . '></p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[43] . ' ' . INST_helpLink('db_prefix') . '</label> <input type="text" name="db_prefix" value="' . htmlspecialchars($db_prefix) . '" size="20"' . XHTML . '></p>

            <br' . XHTML . '>
            <h2>' . $LANG_INSTALL[44] . '</h2> 
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[45] . ' ' . INST_helpLink('site_url') . '</label> <input type="text" name="site_url" value="' . htmlspecialchars($site_url) . '" size="50"' . XHTML . '>  &nbsp; ' . $LANG_INSTALL[46] . '</p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[47] . ' ' . INST_helpLink('site_admin_url') . '</label> <input type="text" name="site_admin_url" value="' . htmlspecialchars($site_admin_url) . '" size="50"' . XHTML . '>  &nbsp; ' . $LANG_INSTALL[46] . '</p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[48] . ' ' . INST_helpLink('site_mail') . '</label> <input type="text" name="site_mail" value="' . htmlspecialchars($site_mail) . '" size="50"' . XHTML . '></p>
            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[49] . ' ' . INST_helpLink('noreply_mail') . '</label> <input type="text" name="noreply_mail" value="' . htmlspecialchars($noreply_mail) . '" size="50"' . XHTML . '></p>';
            if ($install_type == 'install') {
                $display .= '
                <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[92] . ' ' . INST_helpLink('utf8') . '</label> <input type="checkbox" name="utf8"' . ($utf8 ? ' checked="checked"' : '') . XHTML . '></p>';
            }
            $display .= '<br' . XHTML . '>
            <input type="submit" name="submit" class="submit button big-button" value="' . $buttontext . ' &gt;&gt;"' . XHTML . '>
            <input type="submit" name="install_plugins" class="submit button big-button" value="' . $buttontext . ' ' . $LANG_INSTALL[103] . ' &gt;&gt;"' . XHTML . '>
            </form>' . LB;
            break;
            /**
             * Page 2 - Enter information into db-config.php
             * and ask about InnoDB tables (if supported)
             */
        /**
         * Page 2 - Enter information into db-config.php
         * and ask about InnoDB tables (if supported)
         */
        case 2:
            // Set all the variables from the received POST data.
            $site_name = $_POST['site_name'];
            $site_slogan = $_POST['site_slogan'];
            $site_url = $_POST['site_url'];
            $site_admin_url = $_POST['site_admin_url'];
            $site_mail = $_POST['site_mail'];
            $noreply_mail = $_POST['noreply_mail'];
            $utf8 = isset($_POST['utf8']) && $_POST['utf8'] == 'on' ? true : false;
            $install_plugins = isset($_POST['install_plugins']) ? true : false;
            $DB = array('type' => $_POST['db_type'], 'host' => $_POST['db_host'], 'name' => $_POST['db_name'], 'user' => $_POST['db_user'], 'pass' => $_POST['db_pass'], 'table_prefix' => $_POST['db_prefix']);
            // Check if $site_admin_url is correct
            if (!INST_urlExists($site_admin_url)) {
                $display .= '<h2>' . $LANG_INSTALL[104] . '</h2><p>' . $LANG_INSTALL[105] . '</p>' . INST_showReturnFormData($_POST) . LB;
                // Check if we can connect to the database
            } else {
                if (!INST_dbConnect($DB)) {
                    $display .= '<h2>' . $LANG_INSTALL[54] . '</h2><p>' . $LANG_INSTALL[55] . '</p>' . INST_showReturnFormData($_POST) . LB;
                    // Check if the user's version of MySQL is out of date
                } else {
                    if (INST_mysqlOutOfDate($DB)) {
                        $myv = mysql_v($DB['host'], $DB['user'], $DB['pass']);
                        $display .= '<h1>' . sprintf($LANG_INSTALL[51], SUPPORTED_MYSQL_VER) . '</h1>' . LB;
                        $display .= '<p>' . sprintf($LANG_INSTALL[52], SUPPORTED_MYSQL_VER) . $myv[0] . '.' . $myv[1] . '.' . $myv[2] . $LANG_INSTALL[53] . '</p>' . LB;
                        // Check if database doesn't exist
                    } else {
                        if (!INST_dbExists($DB)) {
                            $display .= '<h2>' . $LANG_INSTALL[56] . '</h2><p>' . $LANG_INSTALL[57] . '</p>' . INST_showReturnFormData($_POST) . LB;
                        } else {
                            // Write the database info to db-config.php
                            if (!INST_writeConfig($dbconfig_path, $DB)) {
                                exit($LANG_INSTALL[26] . ' ' . htmlspecialchars($dbconfig_path) . $LANG_INSTALL[58]);
                            }
                            // for the default charset, patch siteconfig.php again
                            if ($install_type != 'upgrade') {
                                if (!INST_setDefaultCharset($siteconfig_path, $utf8 ? 'utf-8' : $LANG_CHARSET)) {
                                    exit($LANG_INSTALL[26] . ' ' . $siteconfig_path . $LANG_INSTALL[58]);
                                }
                            }
                            require $dbconfig_path;
                            require_once $siteconfig_path;
                            require_once $_CONF['path_system'] . 'lib-database.php';
                            $req_string = 'index.php?mode=' . $install_type . '&step=3&dbconfig_path=' . $dbconfig_path . '&install_plugins=' . $install_plugins . '&language=' . $language . '&site_name=' . urlencode($site_name) . '&site_slogan=' . urlencode($site_slogan) . '&site_url=' . urlencode($site_url) . '&site_admin_url=' . urlencode($site_admin_url) . '&site_mail=' . urlencode($site_mail) . '&noreply_mail=' . urlencode($noreply_mail);
                            if ($utf8) {
                                $req_string .= '&utf8=true';
                            }
                            switch ($install_type) {
                                case 'install':
                                    $hidden_fields = '<input type="hidden" name="mode" value="' . $install_type . '"' . XHTML . '>
                            <input type="hidden" name="language" value="' . $language . '"' . XHTML . '>
                            <input type="hidden" name="dbconfig_path" value="' . htmlspecialchars($dbconfig_path) . '"' . XHTML . '>
                            <input type="hidden" name="site_name" value="' . urlencode($site_name) . '"' . XHTML . '>
                            <input type="hidden" name="site_slogan" value="' . urlencode($site_slogan) . '"' . XHTML . '>
                            <input type="hidden" name="site_url" value="' . urlencode($site_url) . '"' . XHTML . '>
                            <input type="hidden" name="site_admin_url" value="' . urlencode($site_admin_url) . '"' . XHTML . '>
                            <input type="hidden" name="site_mail" value="' . urlencode($site_mail) . '"' . XHTML . '>
                            <input type="hidden" name="noreply_mail" value="' . urlencode($noreply_mail) . '"' . XHTML . '>
                            <input type="hidden" name="utf8" value="' . ($utf8 ? 'true' : 'false') . '"' . XHTML . '>';
                                    // If using MySQL check to see if InnoDB is supported
                                    if ($DB['type'] == 'mysql-innodb' && !INST_innodbSupported()) {
                                        // Warn that InnoDB tables are not supported
                                        $display .= '<h2>' . $LANG_INSTALL[59] . '</h2>
                    <p>' . $LANG_INSTALL['60'] . '</p>

                    <br' . XHTML . '>
                    <div style="margin-left: auto; margin-right: auto; width: 125px">
                        <div style="position: relative; right: 10px">
                            <form action="index.php" method="post">
                            <input type="hidden" name="language" value="' . $language . '"' . XHTML . '>
                            <input type="hidden" name="step" value="1"' . XHTML . '>
                            ' . $hidden_fields . '
                            <input type="submit" class="button big-button" value="&lt;&lt; ' . $LANG_INSTALL[61] . '"' . XHTML . '>
                            </form>
                        </div>

                        <div style="position: relative; left: 65px; top: -27px">
                            <form action="index.php" method="post">
                            <input type="hidden" name="language" value="' . $language . '"' . XHTML . '>
                            <input type="hidden" name="step" value="3"' . XHTML . '>
                            ' . $hidden_fields . '
                            <input type="hidden" name="innodb" value="false"' . XHTML . '>
                            <input type="submit" class="button big-button" name="submit" value="' . $LANG_INSTALL[62] . ' &gt;&gt;"' . XHTML . '>
                            </form>
                        </div>
                    </div>' . LB;
                                    } else {
                                        // Continue on to step 3 where the installation will happen
                                        if ($DB['type'] == 'mysql-innodb') {
                                            $req_string .= '&innodb=true';
                                        }
                                        header('Location: ' . $req_string);
                                    }
                                    break;
                                case 'upgrade':
                                    // Try and find out what the current version of GL is
                                    $curv = INST_identifyGeeklogVersion();
                                    if ($curv == VERSION) {
                                        // If current version is the newest version
                                        // then there's no need to update.
                                        $display .= '<h2>' . $LANG_INSTALL[74] . '</h2>' . LB . '<p>' . $LANG_INSTALL[75] . '</p>';
                                    } elseif ($curv == 'empty') {
                                        $display .= '<h2>' . $LANG_INSTALL[90] . '</h2>' . LB . '<p>' . $LANG_INSTALL[91] . '</p>';
                                    } else {
                                        $old_versions = array('1.2.5-1', '1.3', '1.3.1', '1.3.2', '1.3.2-1', '1.3.3', '1.3.4', '1.3.5', '1.3.6', '1.3.7', '1.3.8', '1.3.9', '1.3.10', '1.3.11', '1.4.0', '1.4.1', '1.5.0', '1.5.1', '1.5.2', '1.6.0');
                                        if (empty($curv)) {
                                            // If we were unable to determine the current GL
                                            // version is then ask the user what it is
                                            $display .= '<h2>' . $LANG_INSTALL[76] . '</h2>
                            <p>' . $LANG_INSTALL[77] . '</p>
                            <form action="index.php" method="post">
                            <input type="hidden" name="mode" value="upgrade"' . XHTML . '>
                            <input type="hidden" name="step" value="3"' . XHTML . '>
                            <input type="hidden" name="dbconfig_path" value="' . htmlspecialchars($dbconfig_path) . '"' . XHTML . '>
                            <p><label class="' . $form_label_dir . '">' . $LANG_INSTALL[89] . '</label> <select name="version">';
                                            $tmp_counter = 0;
                                            $ver_selected = '';
                                            foreach ($old_versions as $version) {
                                                if ($tmp_counter == count($old_versions) - 1) {
                                                    $ver_selected = ' selected="selected"';
                                                }
                                                $display .= LB . '<option' . $ver_selected . '>' . $version . '</option>';
                                                $tmp_counter++;
                                            }
                                            $display .= '</select></p>
                            <br' . XHTML . '>
                            <input type="submit" name="submit" class="submit button big-button" value="' . $LANG_INSTALL[25] . ' &gt;&gt;"' . XHTML . '>
                            </form>' . LB;
                                            $curv = $old_versions[count($old_versions) - 1];
                                        } else {
                                            // Continue on to step 3 where the upgrade will happen
                                            header('Location: ' . $req_string . '&version=' . $curv);
                                        }
                                    }
                                    break;
                            }
                        }
                    }
                }
            }
            break;
            /**
             * Page 3 - Install
             */
        /**
         * Page 3 - Install
         */
        case 3:
            $gl_path = str_replace('db-config.php', '', $dbconfig_path);
            $install_plugins = isset($_REQUEST['install_plugins']) && !empty($_REQUEST['install_plugins']) ? true : false;
            $next_link = $install_plugins ? 'install-plugins.php?language=' . $language : 'success.php?type=' . $install_type . '&language=' . $language;
            switch ($install_type) {
                case 'install':
                    if (isset($_POST['submit']) && $_POST['submit'] == '<< ' . $LANG_INSTALL[61]) {
                        header('Location: index.php?mode=install');
                    }
                    // Check whether to use InnoDB tables
                    $use_innodb = false;
                    if (isset($_POST['innodb']) && $_POST['innodb'] == 'true' || isset($_GET['innodb']) && $_GET['innodb'] == 'true') {
                        $use_innodb = true;
                    }
                    $utf8 = false;
                    if (isset($_POST['utf8']) && $_POST['utf8'] == 'true' || isset($_GET['utf8']) && $_GET['utf8'] == 'true') {
                        $utf8 = true;
                    }
                    // We need all this just to do one DB query
                    require_once $dbconfig_path;
                    require_once $siteconfig_path;
                    require_once $_CONF['path_system'] . 'lib-database.php';
                    // Check if GL is already installed
                    if (INST_checkTableExists('vars')) {
                        $display .= '<p>' . $LANG_INSTALL[63] . '</p>
                        <ol>
                            <li>' . $LANG_INSTALL[64] . '</li>
                            <li>' . $LANG_INSTALL[65] . '</li>
                        </ol>

                        <div style="margin-left: auto; margin-right: auto; width: 175px">
                            <div style="position: absolute">
                                <form action="index.php" method="post">
                                <input type="hidden" name="mode" value="install"' . XHTML . '>
                                <input type="hidden" name="step" value="3"' . XHTML . '>
                                <input type="hidden" value="' . $language . '"' . XHTML . '>
                                <input type="hidden" name="dbconfig_path" value="' . htmlspecialchars($dbconfig_path) . '"' . XHTML . '>
                                <input type="hidden" name="innodb" value="' . ($use_innodb ? 'true' : 'false') . '"' . XHTML . '>
                                <input type="hidden" name="install_plugins" value="' . $install_plugins . '"' . XHTML . '>
                                <input type="submit" class="button big-button" value="' . $LANG_INSTALL[66] . '"' . XHTML . '>
                                </form>
                            </div>

                            <div style="position: relative; left: 105px; top: 5px">
                                <form action="index.php" method="post">
                                <input type="hidden" name="mode" value="upgrade"' . XHTML . '>
                                <input type="hidden" name="language" value="' . $language . '"' . XHTML . '>
                                <input type="hidden" name="dbconfig_path" value="' . htmlspecialchars($dbconfig_path) . '"' . XHTML . '>
                                <input type="submit" class="button big-button" value="' . $LANG_INSTALL[25] . '"' . XHTML . '>
                                </form>
                            </div>
                        </div>
                        ' . LB;
                    } else {
                        if (INST_createDatabaseStructures()) {
                            $site_name = isset($_POST['site_name']) ? $_POST['site_name'] : (isset($_GET['site_name']) ? $_GET['site_name'] : '');
                            $site_slogan = isset($_POST['site_slogan']) ? $_POST['site_slogan'] : (isset($_GET['site_slogan']) ? $_GET['site_slogan'] : '');
                            $site_url = isset($_POST['site_url']) ? $_POST['site_url'] : (isset($_GET['site_url']) ? $_GET['site_url'] : '');
                            $site_admin_url = isset($_POST['site_admin_url']) ? $_POST['site_admin_url'] : (isset($_GET['site_admin_url']) ? $_GET['site_admin_url'] : '');
                            $site_mail = isset($_POST['site_mail']) ? $_POST['site_mail'] : (isset($_GET['site_mail']) ? $_GET['site_mail'] : '');
                            $noreply_mail = isset($_POST['noreply_mail']) ? $_POST['noreply_mail'] : (isset($_GET['noreply_mail']) ? $_GET['noreply_mail'] : '');
                            INST_personalizeAdminAccount($site_mail, $site_url);
                            // Insert the form data into the conf_values table
                            require_once $_CONF['path_system'] . 'classes/config.class.php';
                            require_once 'config-install.php';
                            install_config();
                            $config = config::get_instance();
                            $config->set('site_name', urldecode($site_name));
                            $config->set('site_slogan', urldecode($site_slogan));
                            $config->set('site_url', urldecode($site_url));
                            $config->set('site_admin_url', urldecode($site_admin_url));
                            $config->set('site_mail', urldecode($site_mail));
                            $config->set('noreply_mail', urldecode($noreply_mail));
                            $config->set('path_html', $html_path);
                            $config->set('path_log', $gl_path . 'logs/');
                            $config->set('path_language', $gl_path . 'language/');
                            $config->set('backup_path', $gl_path . 'backups/');
                            $config->set('path_data', $gl_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/');
                            $config->set_default('default_photo', urldecode($site_url) . '/default.jpg');
                            $lng = INST_getDefaultLanguage($gl_path . 'language/', $language, $utf8);
                            if (!empty($lng)) {
                                $config->set('language', $lng);
                            }
                            INST_setVersion($siteconfig_path);
                            if (!$install_plugins) {
                                // do a default install of all available plugins
                                /**
                                 * For the plugin install we would actually need
                                 * lib-common.php in the global namespace. Since
                                 * we're in a function, we need to hack a few
                                 * things and rely on a few global declarations
                                 * (see beginning of function).
                                 */
                                // Hack: not needed here - avoid notice
                                $_DB_mysqldump_path = '';
                                // Hack: lib-common will overwrite $language
                                $lx_inst = $language;
                                require_once '../../lib-common.php';
                                $language = $lx_inst;
                                INST_defaultPluginInstall();
                            }
                            // Installation is complete. Continue onto either
                            // custom plugin installation page or success page
                            header('Location: ' . $next_link);
                        } else {
                            $display .= "<h2>" . $LANG_INSTALL[67] . "</h2><p>" . $LANG_INSTALL[68] . "</p>";
                        }
                    }
                    break;
                case 'upgrade':
                    // Get and set which version to display
                    $version = '';
                    if (isset($_GET['version'])) {
                        $version = $_GET['version'];
                    } else {
                        if (isset($_POST['version'])) {
                            $version = $_POST['version'];
                        }
                    }
                    // Let's do this
                    require_once $dbconfig_path;
                    require_once $siteconfig_path;
                    require_once $_CONF['path_system'] . 'lib-database.php';
                    // If this is a MySQL database check to see if it was
                    // installed with InnoDB support
                    if ($_DB_dbms == 'mysql') {
                        // Query `vars` and see if 'database_engine' == 'InnoDB'
                        $result = DB_query("SELECT `name`,`value` FROM {$_TABLES['vars']} WHERE `name`='database_engine'");
                        $row = DB_fetchArray($result);
                        if ($row['value'] == 'InnoDB') {
                            $use_innodb = true;
                        } else {
                            $use_innodb = false;
                        }
                    }
                    if (INST_doDatabaseUpgrades($version)) {
                        if (version_compare($version, '1.5.0') == -1) {
                            // After updating the database we'll want to update some of the information from the form.
                            $site_name = isset($_POST['site_name']) ? $_POST['site_name'] : (isset($_GET['site_name']) ? $_GET['site_name'] : '');
                            $site_slogan = isset($_POST['site_slogan']) ? $_POST['site_slogan'] : (isset($_GET['site_slogan']) ? $_GET['site_slogan'] : '');
                            $site_url = isset($_POST['site_url']) ? $_POST['site_url'] : (isset($_GET['site_url']) ? $_GET['site_url'] : '');
                            $site_admin_url = isset($_POST['site_admin_url']) ? $_POST['site_admin_url'] : (isset($_GET['site_admin_url']) ? $_GET['site_admin_url'] : '');
                            $site_mail = isset($_POST['site_mail']) ? $_POST['site_mail'] : (isset($_GET['site_mail']) ? $_GET['site_mail'] : '');
                            $noreply_mail = isset($_POST['noreply_mail']) ? $_POST['noreply_mail'] : (isset($_GET['noreply_mail']) ? $_GET['noreply_mail'] : '');
                            require_once $_CONF['path_system'] . 'classes/config.class.php';
                            $config = config::get_instance();
                            $config->set('site_name', urldecode($site_name));
                            $config->set('site_slogan', urldecode($site_slogan));
                            $config->set('site_url', urldecode($site_url));
                            $config->set('site_admin_url', urldecode($site_admin_url));
                            $config->set('site_mail', urldecode($site_mail));
                            $config->set('noreply_mail', urldecode($noreply_mail));
                            $config->set_default('default_photo', urldecode($site_url) . '/default.jpg');
                        } else {
                            $site_url = isset($_POST['site_url']) ? $_POST['site_url'] : (isset($_GET['site_url']) ? $_GET['site_url'] : '');
                            $site_admin_url = isset($_POST['site_admin_url']) ? $_POST['site_admin_url'] : (isset($_GET['site_admin_url']) ? $_GET['site_admin_url'] : '');
                        }
                        INST_fixPathsAndUrls($_CONF['path'], $html_path, urldecode($site_url), urldecode($site_admin_url));
                        // disable plugins for which we don't have the source files
                        INST_checkPlugins();
                        // extra step 4: upgrade plugins
                        $next_link = 'index.php?step=4&mode=' . $install_type . '&language=' . $language;
                        if ($install_plugins) {
                            $next_link .= '&install_plugins=true';
                        }
                        header('Location: ' . $next_link);
                    } else {
                        $display .= '<h2>' . $LANG_INSTALL[78] . '</h2>
                        <p>' . $LANG_INSTALL[79] . '</p>' . LB;
                    }
                    break;
            }
            break;
            /**
             * Extra Step 4 - Upgrade plugins
             */
        /**
         * Extra Step 4 - Upgrade plugins
         */
        case 4:
            INST_pluginUpgrades();
            $install_plugins = isset($_GET['install_plugins']) && !empty($_GET['install_plugins']) ? true : false;
            if (!$install_plugins) {
                // if we don't do the manual selection, install all new plugins now
                INST_autoinstallNewPlugins();
            }
            $next_link = $install_plugins ? 'install-plugins.php?language=' . $language : 'success.php?type=' . $install_type . '&language=' . $language;
            header('Location: ' . $next_link);
            break;
    }
}
Exemple #2
0
                     if (strpos($line, 'DEFAULT CHARSET=utf8') !== false) {
                         $db_connection_charset = 'utf8';
                     }
                 }
             }
         }
         fclose($sql_file);
         if ($num_create <= 1) {
             // this doesn't look like an SQL dump ...
             $display .= INST_getAlertMsg(sprintf($LANG_MIGRATE[43], $backupFile));
         } else {
             // Update db-config.php with the table prefix from the backup file.
             if (!INST_writeConfig($dbconfig_path, $DB)) {
                 exit($LANG_INSTALL[26] . ' ' . $dbconfig_path . $LANG_INSTALL[58]);
             }
             if (!INST_setDefaultCharset($siteconfig_path, $db_connection_charset == 'utf8' ? 'utf-8' : $LANG_CHARSET)) {
                 exit($LANG_INSTALL[26] . ' ' . $siteconfig_path . $LANG_INSTALL[58]);
             }
             // Send file to bigdump.php script to do the import.
             header('Location: bigdump.php?start=1&foffset=0&totalqueries=0' . '&db_connection_charset=' . $db_connection_charset . '&language=' . $language . '&fn=' . urlencode($backup_dir . $backupFile) . '&site_url=' . urlencode($_REQUEST['site_url']) . '&site_admin_url=' . urlencode($_REQUEST['site_admin_url']));
         }
     }
     break;
     /**
      * Page 4 - Post-import operations
      * Update the database, if necessary. Then check for missing plugins,
      * incorrect paths, and other required Geeklog files
      */
 /**
  * Page 4 - Post-import operations
  * Update the database, if necessary. Then check for missing plugins,
Exemple #3
0
/**
 * 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;
}