[答案:] 从 phpNuke 迁移到 Xoops 的网站可能很容易或很复杂,这取决于原始网站中包含的内容。这篇文章包含一个脚本,可以将 phpNuke 用户转换为 Xoops 用户。此外,您可能还需要转换新闻部分、论坛等部分的条目。这些将在其他地方介绍。注意:以下脚本需要编辑。将其粘贴到您喜欢的文本编辑器中,并仔细阅读,指令在最上面。
/*************************************************
Script to convert phpNuke users into Xoops users.
I wrote this because I couldn't find it elsewhere.
Don't get mad if it doesn't work without hacking for you,
I had to hack a lot to make it work for me... :o)
Written by earplane (http://www.earplane.com)
Released as is, use at your own risk. Please know what you're doing.
Requirements:
1. A clean working Xoops site with only one registered user, the Admin account.
2. Preferably phpMyAdmin access.
3. Know your MySQL username and password.
4. Know your MySQL host name and the name of your xoops database.
5. Make sure that your Admin account username hasn't been used by a phpnuke user.
Steps:
1. Export the table nuke_users with structure and data from the phpNuke database.
2. Run the sql file to insert the nuke_users table inside your Xoops database.
3. Edit this file entering you mySQL username and password
4. Upload this script to your site.
5. Make a backup of your xoops_user table, naming the copy xoops_users_old.
6. Run this script from a browser window. IMPORTANT!!! RUN THIS SCRIPT ONLY ONCE!!!
7. Browse output to check for error messages. If there are error messages you'll
have to edit this script to get rid of them. IMPORTANT: if a user failed it'll most
likely be because of some comma somewhere. If you find the problem you can skip the
offending fields in the queries below and try again. BUT!!!! You'll first have to
drop your xoops_users table and restore it from the xoops_users_old copy. You don't
want duplicate entries, that will break this script.
8. Delete this script from your site.
*******************************************************/
/********************************
TODO:
1. Make a user interface for this script?
***********************************/
/*********** Edit this section to suit your needs! **********/
/* Enter your mySQL host name */
$dbHost = "localhost";
/* Enter your mySQL username */
$dbUser = "myDBusername";
/* Enter your mySQL password */
$dbPass = "myDBpassword";
/* Enter the name of your xoops database */
$xoopsDB = "myDBdatabase";
/********** End of edit section *******/
// Connect to DataBase
$db = mysql_connect($dbHost, $dbUser, $dbPass)
or die("Could not connect: " . mysql_error());
if ($xoopsDB!="" and !@mysql_select_db($xoopsDB))
die("The site database is unavailable.");
// Get phpNuke Users
$sql = "SELECT * FROM nuke_users ORDER BY 1";
$result = mysql_query($sql);
$userIndex = 1; // This is the Xoops Admin userid, and the index will increment from it.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
// phpNuke has Anonymous as first user while Xoops has admin, so skip the first user.
if ($row["user_id"] == '1') {
echo "Admin skipped!
";
continue;
}
// Read info from user:
$uid = $row["user_id"];
$name = $row["name"];
$uname = $row["username"];
$email = $row["user_email"];
$url = $row["user_website"];
$user_avatar = $row["user_avatar"];
$user_regdate = strtotime($row["user_regdate"]);
$user_icq = $row["user_icq"];
$user_from = $row["user_from"];
$user_sig = $row["user_sig"];
$user_viewemail = $row["user_viewemail"];
$actkey = $row["user_actkey"];
$user_aim = $row["user_aim"];
$user_yim = $row["user_yim"];
$user_msnm = $row["user_msnm"];
$pass = $row["user_password"];
$posts = $row["user_posts"];
$attachsig = $row["user_attachsig"];
$rank = $row["user_rank"];
$level = $row["user_level"];
$theme = $row["theme"];
$timezone_offset = $row["user_timezone"];
$last_login = $row["user_lastvisit"];
$umode = $row["umode"];
$uorder = $row["uorder"];
$notify_method = 0;
$user_occ = $row["user_occ"];
$bio = $row["bio"];
$user_intrest = $row["user_interests"];
$user_mailok = $row["user_notify"];
$sql = "INSERT INTO xoops_users SET name='$name', uname='$uname', email='$email',
url='$url', user_avatar='$user_avatar', user_regdate='$user_regdate',
user_icq='$user_icq', user_from='$user_from', user_sig='$user_sig',
user_viewemail='$user_viewemail', actkey='$actkey', user_aim='$user_aim',
user_yim='$user_yim', user_msnm='$user_msnm', pass='$pass', posts='$posts',
attachsig='$attachsig', rank='$rank', level='$level', theme='$theme',
timezone_offset='$timezone_offset', last_login='$last_login', umode='$umode',
uorder='$uorder', notify_method='$notify_method', user_occ='$user_occ', bio='$bio',
user_intrest='$user_intrest', user_mailok='$user_mailok'";
// Insert converted user in xoops database
if (mysql_query($sql)) {
echo $uname . " was successfully converted.
";
} else {
// If fail there may have been a comma somewhere that broke things.
echo "Second attempt on " . $uname . ":
";
// Try without bio, interests, avatar and signature
$sql = "INSERT INTO xoops_users SET name='$name', uname='$uname', email='$email',
url='$url', user_regdate='$user_regdate',
user_icq='$user_icq', user_from='$user_from',
user_viewemail='$user_viewemail', actkey='$actkey', user_aim='$user_aim',
user_yim='$user_yim', user_msnm='$user_msnm', pass='$pass', posts='$posts',
attachsig='$attachsig', rank='$rank', level='$level', theme='$theme',
timezone_offset='$timezone_offset', last_login='$last_login', umode='$umode',
uorder='$uorder', notify_method='$notify_method', user_occ='$user_occ',
user_mailok='$user_mailok'";
if (mysql_query($sql)) {
echo $uname . " was successfully converted on the second attempt.
";
} else {
// Sorry, there is no third attempt in this script. Try to spot the problem from the output...
echo "
Ooops! The second attempt failed on" . $uname . "!!!!!!!
" . $sql . "
";
}
}
/**** Update the user ID *****/
$sql = "UPDATE xoops_users SET uid='$uid' WHERE uname='$uname'";
mysql_query($sql);
/*** Set group link *****/
$sql = "INSERT INTO xoops_groups_users_link SET groupid=2, uid='$uid'";
mysql_query($sql);
}
?>
Mithrandir 善意地为我“Xoopsify”了代码。我的版本对我适用良好,所以我还没有尝试他的代码。但是,我从阅读它中学到了很多关于 Xoops 考虑方式的知识:
// Pop this in the XOOPS root folder
require "mainfile.php";
// Get member handler instance for later use
$member_handler =& xoops_gethandler('member');
// Get phpNuke Users
$sql = "SELECT * FROM nuke_users WHERE user_id > 1";
$result = $xoopsDB->query($sql);
while ($row = $xoopsDB->fetchArray($result))
{
// create user object
$user =& $member_handler->create();
$user->setVar('uid', $row["user_id"]);
$user->setVar('name', $row["name"]);
$user->setVar('uname', $row["username"]);
$user->setVar('email', $row["user_email"]);
$user->setVar('url', $row["user_website"]);
$user->setVar('user_avatar', $row["user_avatar"]);
$user->setVar('user_regdate', strtotime($row["user_regdate"]));
$user->setVar('user_icq', $row["user_icq"]);
$user->setVar('user_from', $row["user_from"]);
$user->setVar('user_sig', $row["user_sig"]);
$user->setVar('user_viewemail', $row["user_viewemail"]);
$user->setVar('actkey', $row["user_actkey"]);
$user->setVar('user_aim', $row["user_aim"]);
$user->setVar('user_yim', $row["user_yim"]);
$user->setVar('user_msnm', $row["user_msnm"]);
$user->setVar('pass', $row["user_password"]);
$user->setVar('posts', $row["user_posts"]);
$user->setVar('attachsig', $row["user_attachsig"]);
$user->setVar('rank', $row["user_rank"]);
$user->setVar('level', $row["user_level"]);
$user->setVar('theme', $row["theme"]);
$user->setVar('timezone_offset', $row["user_timezone"]);
$user->setVar('last_login', $row["user_lastvisit"]);
$user->setVar('umode', $row["umode"]);
$user->setVar('uorder', $row["uorder"]);
$user->setVar('notify_method', 0);
$user->setVar('user_occ', $row["user_occ"]);
$user->setVar('bio', $row["bio"]);
$user->setVar('user_intrest', $row["user_interests"]);
$user->setVar('user_mailok', $row["user_notify"]);
// Insert converted user in xoops database
if ($member_handler->insertUser($user)) {
echo $uname . " was successfully converted.
";
} else {
echo "
Insertion failed on" . $uname . "!
".$user->getHtmlErrors().""";
}
/*** Set group link *****/
$member_handler->addUserToGroup(XOOPS_GROUP_USERS, $user->getVar('uid'));
}
?>
将 NUKE -> XOOPS 转换
非常好的常见问题解答,
此脚本可以用于几乎任何 Nuke 分支,只需做少量调整。