function nv_create_table($table, $dbms_data, $drop = true)
{
    global $db, $table_prefix, $db_schema, $delimiter;
    $table_name = substr($table . '#', 6, -1);
    $db_schema = $dbms_data['db_schema'];
    $delimiter = $dbms_data['delimiter'];
    if ($drop) {
        nv_drop_table($table);
    }
    // locate the schema files
    $dbms_schema = 'schemas/' . $table . '/_' . $db_schema . '_schema.sql';
    $sql_query = @file_get_contents($dbms_schema);
    $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
    $sql_query = preg_replace('/\\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql_query));
    $sql_query = split_sql_file($sql_query, $delimiter);
    // make the new one's
    foreach ($sql_query as $sql) {
        if (!$db->sql_query($sql)) {
            $error = $db->sql_error();
            $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
        }
    }
    unset($sql_query);
}
    /**
     * Load the contents of the schema into the database and then alter it based on what has been input during the installation
     */
    function delete_tables($mode, $sub)
    {
        global $auth, $cache, $db, $template, $user, $phpbb_root_path, $phpEx;
        $this->page_title = $user->lang['STAGE_DELETE_TABLES'];
        $db->sql_return_on_error(true);
        // Delete the tables
        nv_drop_table(GALLERY_ALBUMS_TABLE);
        nv_drop_table(GALLERY_ATRACK_TABLE);
        nv_drop_table(GALLERY_COMMENTS_TABLE);
        nv_drop_table(GALLERY_CONFIG_TABLE);
        nv_drop_table(GALLERY_CONTESTS_TABLE);
        nv_drop_table(GALLERY_FAVORITES_TABLE);
        nv_drop_table(GALLERY_IMAGES_TABLE);
        nv_drop_table(GALLERY_MODSCACHE_TABLE);
        nv_drop_table(GALLERY_PERMISSIONS_TABLE);
        nv_drop_table(GALLERY_RATES_TABLE);
        nv_drop_table(GALLERY_REPORTS_TABLE);
        nv_drop_table(GALLERY_ROLES_TABLE);
        nv_drop_table(GALLERY_USERS_TABLE);
        nv_drop_table(GALLERY_WATCH_TABLE);
        nv_drop_table('phpbb_album');
        nv_drop_table('phpbb_album_cat');
        nv_drop_table('phpbb_album_comment');
        nv_drop_table('phpbb_album_config');
        nv_drop_table('phpbb_album_rate');
        // Delete columns
        nv_remove_column(SESSIONS_TABLE, 'session_album_id');
        nv_remove_column(LOG_TABLE, 'album_id');
        nv_remove_column(LOG_TABLE, 'image_id');
        nv_remove_column(USERS_TABLE, 'album_id');
        $db->sql_return_on_error(false);
        // Delete default config
        $config_ary = array('gallery_user_images_profil', 'gallery_personal_album_profil', 'gallery_viewtopic_icon', 'gallery_viewtopic_images', 'gallery_viewtopic_link', 'num_images', 'gallery_total_images');
        $sql = 'DELETE FROM ' . CONFIG_TABLE . '
			WHERE ' . $db->sql_in_set('config_name', $config_ary);
        $db->sql_query($sql);
        $auth_admin = array('a_gallery_manage', 'a_gallery_albums', 'a_gallery_import', 'a_gallery_cleanup');
        $sql = 'SELECT auth_option_id, is_global, is_local
			FROM ' . ACL_OPTIONS_TABLE . '
			WHERE ' . $db->sql_in_set('auth_option', $auth_admin) . '
				AND is_global = 1';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $id = $row['auth_option_id'];
            // If it is a local and global permission, do not remove the row! :P
            if ($row['is_global'] && $row['is_local']) {
                $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . '
					SET is_global = 0
					WHERE auth_option_id = ' . $id;
                $this->db->sql_query($sql);
            } else {
                // Delete time
                $db->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $id);
                $db->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $id);
                $db->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $id);
                $db->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $id);
            }
        }
        $db->sql_freeresult($result);
        // Purge the auth cache
        $cache->destroy('_acl_options');
        $auth->acl_clear_prefetch();
        $log_modules = "(module_basename = 'logs'\n\t\t\tAND module_class = 'acp'\n\t\t\tAND module_mode = 'gallery')";
        $ucp_modules = "(module_class = 'ucp'\n\t\t\tAND (module_basename = 'gallery'\n\t\t\t\tOR module_langname = 'UCP_GALLERY'))";
        $acp_modules = "(module_class = 'acp'\n\t\t\tAND (module_basename LIKE 'gallery%'\n\t\t\t\tOR module_langname = 'PHPBB_GALLERY'))";
        $sql = 'SELECT module_id, module_class
			FROM ' . MODULES_TABLE . '
			WHERE ' . $log_modules . ' OR ' . $ucp_modules . ' OR ' . $acp_modules . '
			ORDER BY left_id DESC';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            remove_module($row['module_id'], $row['module_class']);
        }
        $db->sql_freeresult($result);
        $p_class = str_replace(array('.', '/', '\\'), '', basename('acp'));
        $cache->destroy('_modules_' . $p_class);
        $p_class = str_replace(array('.', '/', '\\'), '', basename('ucp'));
        $cache->destroy('_modules_' . $p_class);
        // Additionally remove sql cache
        $cache->destroy('sql', MODULES_TABLE);
        $db->sql_query('DELETE FROM ' . BBCODES_TABLE . "\n\t\t\tWHERE bbcode_tag = 'album'");
        $cache->destroy('sql', BBCODES_TABLE);
        $template->assign_vars(array('BODY' => $user->lang['STAGE_CREATE_TABLE_EXPLAIN'], 'L_SUBMIT' => $user->lang['NEXT_STEP'], 'S_HIDDEN' => '', 'U_ACTION' => append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=final")));
    }