I have a fantasy drum corps league section of my Website that I've scripted and tied to my UBB user database. My fantasy corps were each tied to their respective owner by their member number in the UBB database. When I updated from UBB6 to UBB7, this was all thrown out of wack, so I wrote a little script to solve the problem. I know it's not exactly what you need, since it's scripted exactly for my purpose and my purpose only, but it's the same idea (comparing user numbers from one version to the next and changing them accordingly.) Maybe you can get some use out of it and it can at least give you some ideas or work as a starting-off point.

Anyway, just remember that running any sort of script like this is dangerous if it doesn't do exactly what you want it to do, so test it on an offline database and be sure to have a backup of your online before you run it against it.

PHP Code

<?php

if(!defined("UBB_MAIN_PROGRAM")) exit;

function &page_xfix_gpc () {
	return array(
		"wordlets" => array("fdc"),
		"admin_or_mod" => 1,
	);
}

function &page_xfix_run () {

	global $html,$myinfo,$smarty,$user,$in,$ubbt_lang,$config,$forumvisit,$visit,$dbh,$var_start,$var_eq,$var_sep,$var_extra;

	extract($in, EXTR_OVERWRITE | EXTR_REFS);
	$Number = $user['USER_ID'];

require ('scripts/xfdc.inc.php');

   $query = "
	  SELECT COUNT(*)
	  FROM  f03_FDCcorps
   ";
   $sth = $dbh -> do_query($query);
   list($totalcorps) = $dbh -> fetch_array($sth);
   $dbh -> finish_sth($sth);

   for($i=0;$i<$totalcorps;$i++){

		$query = "
			SELECT t1.C_UNumber, t1.C_CNumber, t2.U_Username, t3.USER_ID
			FROM f03_FDCcorps AS t1, w3t_Users AS t2, ubbt_USERS AS t3
			WHERE t1.C_CNumber = '$i'
			AND t1.C_UNumber = t2.U_Number
			AND t2.U_Username = t3.USER_DISPLAY_NAME
			";
			$sth = $dbh -> do_query($query);
			
			list($oldunumber, $corpsnumber, $username, $newunumber) = $dbh -> fetch_array($sth);
			
			$userrow[$i]['oldunumber']	= $oldunumber;
			$userrow[$i]['corpsnumber']	= $corpsnumber;
			$userrow[$i]['username']	= $username;
			$userrow[$i]['newunumber']	= $newunumber;
			
			$dbh -> finish_sth($sth);
			
			$query = "
				UPDATE f03_FDCcorps
				SET C_UNumber = '{$userrow[$i]['newunumber']}'
				WHERE C_CNumber = '{$userrow[$i]['corpsnumber']}'
				";
				$dbh -> do_query($query);
			}
			
	return array(
		"header" => array (
			"title" => "Fantasy Drum Corps - 20{$fdcyear} Season",
			"breadcrumb" => <<<BREADCRUMB
 <a href="{$config['BASE_URL']}/ubbthreads.php{$var_start}ubb{$var_eq}cfrm">{$ubbt_lang['FORUM_TEXT']}</a>
 &raquo;
 {$ubbt_lang['LOGIN_PROMPT']}
BREADCRUMB
			,
		),
		"template" => "xshowseason",
		"data" => & $smarty_data,
		"footer" => true,
	);

}

?>


C_UNumber was the user number which was tied to the UBB user number and C_CNumber was the fantasy corps' number.