Exemplo n.º 1
0
    /**
     * Edit the data in the tables
     */
    function update_db_data($mode, $sub)
    {
        global $cache, $db, $template, $user;
        global $phpbb_root_path, $phpEx, $table_prefix;
        include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
        $database_step = request_var('step', 0);
        $this->page_title = $user->lang['STAGE_UPDATE_DB'];
        $next_update_url = '';
        switch (phpbb_gallery_config::get('version')) {
            case '0.1.2':
            case '0.1.3':
            case '0.2.0':
            case '0.2.1':
            case '0.2.2':
            case '0.2.3':
            case '0.3.0':
            case '0.3.1':
            case '0.3.2-RC1':
            case '0.3.2-RC2':
            case '0.4.0-RC1':
            case '0.4.0-RC2':
            case '0.4.0-RC3':
            case '0.4.0':
            case '0.4.1':
            case '0.5.0':
            case '0.5.1-dev':
            case '0.5.1':
            case '0.5.2-dev':
            case '0.5.2':
            case '0.5.3-dev':
            case '0.5.3':
            case '0.5.4':
            case '1.0.0-dev':
            case '1.0.0-RC1':
            case '1.0.0-RC2':
            case '1.0.0':
            case '1.0.1-dev':
            case '1.0.1':
            case '1.0.2-dev':
            case '1.0.2-RC1':
            case '1.0.2':
            case '1.0.3-RC1':
            case '1.0.3-RC2':
            case '1.0.3':
            case '1.0.4':
            case '1.0.5-RC1':
                /**
                 * Cheating?
                 */
                trigger_error('VERSION_NOT_SUPPORTED', E_USER_ERROR);
                break;
            case '1.0.5':
                $sql = 'SELECT *
					FROM ' . GALLERY_CONFIG_TABLE;
                $result = $db->sql_query($sql);
                $old_config = array();
                while ($row = $db->sql_fetchrow($result)) {
                    $old_config[$row['config_name']] = $row['config_value'];
                }
                $db->sql_freeresult($result);
                $others = array('gallery_total_images', 'gallery_viewtopic_icon', 'gallery_viewtopic_images', 'gallery_viewtopic_link');
                foreach ($others as $config_name) {
                    if (isset($config[$config_name])) {
                        $old_config[$config_name] = $config[$config_name];
                    }
                }
                $db->sql_freeresult($result);
                $config_map = config_mapping();
                foreach ($config_map as $old_name => $new_name) {
                    if (isset($old_config[$old_name])) {
                        phpbb_gallery_config::set($new_name, $old_config[$old_name]);
                    }
                }
                // Add new configs:
                $default_config = phpbb_gallery_config::get_default();
                foreach ($default_config as $name => $value) {
                    if (!phpbb_gallery_config::exists($name)) {
                        phpbb_gallery_config::set($name, $value);
                    }
                }
                $next_update_url = append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=update_db&step=4");
                break;
        }
        $next_update_url = !$next_update_url ? append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=update_db&step=4") : $next_update_url;
        $template->assign_vars(array('BODY' => $user->lang['UPDATING_DATA'], 'L_SUBMIT' => $user->lang['NEXT_STEP'], 'S_HIDDEN' => '', 'U_ACTION' => $next_update_url));
    }