<?php
//XOOPS DATABASE SETTINGS
$dbServer='localhost';
$dbUser='YOUR_DBUSERNAME';
$dbPass='YOURDBPASSWORD';
//YOUR 2ND XOOPS DATABASE SETTINGS
$fromDB="2ND_XOOPSDBNAME"; //
$fromPrefix="2ND_XOOPSTABLEPREFIX"; //
//YOUR XOOPS DATABASE SETTINGS
$toDB="YOUR_XOOPSDBNAME"; // XOOPS DATABASE NAME
$toPrefix="YOUR_XOOPSTDBTABLEPREFIX"; // XOOPS PREFIX
//* FUNCTIONS TO CONVERT DATABASE TABLES */
BuildUserTable();
echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>conversion script</title></head><body>";
echo "<font color=blue><b> ** Converting Database **<br>";
$link = mysql_connect($dbServer, $dbUser, $dbPass) or die("Could not connect, check your DB settings");
echo "** Connected successfully **</font></b><p>";
//Function to delete records from the DB
function DeleteRecords($tbname) {
$sql = "DELETE FROM ".$tbname;
$result = mysql_query($sql);
if (!$result) echo(" - delete from $tbname didn't work<br> - <b><font color=red> Broken SQL </font></b>= $sql<br>");
}
//Perform table actions
function DoTable($delete, $sql, $tbname) {
echo "<b>Moving ".$tbname." table</b><br>";
if ($delete) DeleteRecords($tbname);
$result1 = mysql_query($sql);
if (!$result1)
echo(" - $tbname incomplete<br> - <b><font color=red> Broken SQL </font></b>= $sql<br>");
}
// Do the users table - exclude any user that would overwrite XOOPS admin's
function BuildUserTable() {
global $toPrefix, $fromPrefix, $fromDB, $toDB;
$dsql = "DELETE FROM ".$toDB.".".$toPrefix."_users WHERE uid>1";
$sql = "INSERT INTO ".$toDB.".".$toPrefix."_users (SELECT name, uname, email, url, user_avatar, user_regdate, user_icq, user_from, user_sig, user_viewemail, actkey, user_aim, user_yim, user_msnm, pass, posts, attachsig, rank, level, theme, timezone_offset, last_login, umode, uorder, notify_method, notify_mode, user_occ, bio, user_intrest, user_mailok FROM 2ND_XOOPSDBTABLE_USERS)
(SELECT name, uname, email, url, user_avatar, user_regdate, user_icq, user_from, user_sig, user_viewemail, actkey, user_aim, user_yim, user_msnm, pass, posts, attachsig, rank, level, theme, timezone_offset, last_login, umode, uorder, notify_method, notify_mode, user_occ, bio, user_intrest, user_mailok FROM YOUR_XOOPSDBTABLE_USERS)
FROM ".$fromDB.".".$fromPrefix."_users WHERE ".$fromDB.".".$fromPrefix."_users.user_id > '1'";
$delete=False;
$tbname=$toDB.".".$toPrefix."_users";
DoTable($delete, $dsql, $tbname);
DoTable($delete, $sql, $tbname);
$date_array = array('Jan' => '01',
'Feb' => '02',
'Mar' => '03',
'Apr' => '04',
'May' => '05',
'Jun' => '06',
'Jul' => '07',
'Aug' => '08',
'Sep' => '09',
'Oct' => '10',
'Nov' => '11',
'Dec' => '12');
$msql = "SELECT user_id,user_regdate FROM ".$fromDB.".".$fromPrefix."_users WHERE user_id>1";
$result = mysql_query($msql);
if(!$result)
echo(" - Update Regdate failed! ");
while(list($uid,$regdate)=mysql_fetch_row($result)){
$regdate = str_replace(',','',$regdate);
$var = explode(' ',$regdate);
$newdate = mktime(0,0,0,$date_array[$var[0]],$var[1],$var[2]);
$rsql = "UPDATE ".$toDB.".".$toPrefix."_users SET user_regdate='$newdate' WHERE uid='$uid'";
$result1 = mysql_query($rsql);
if(!$result1)
echo(" - Update Regdate failed! ");
}
//=========================================
echo "<p><b><font color=blue>** Disconnected **</font><br>";
echo "<table width=400><font color=red>If you see any errors on this page, I recommend that you
adjust whatever is causing the errors and rerun this script. One thing that you REALLY need to think
about is setting the "buildusertable" to "0" so that you won't over write the XOOPS admin stuff. Use
the table conversion at your own risk!!!</font></table></body>";
mysql_close($link);
?>
That should work but i dont have a test serve to test it right now.
Obviously you will change your database settings through out the script that i have made in CPAITALS.
This is just a modified "bd_csmc" nuke to XOOPS SQL migration script.
Your will see i have modified it to migrate one user table from one XOOPS DB to another user table from your other XOOPS DB.
Im not entirely sure what you are doing, if it is just to migrate one user table to another then this should work but dont do it on a live site... i dont want to be held accountable for that one!.
The orgional script i had to modify to port my users table so i know that it worked for me, but with out testing this script, i dont know!.. i looks ok! as far as the code goes.
I hope that will help you or atleast give some one with way more knowledge than i have a better chance at getting you your users.