Hi,
Here you go. I put in a sql check to see if the user name exists
before the insert. If the username already exists, it by-passes the
instert, otherwise it functions as normal.
<?php
/************************************/
/* Import phpNuke6.0 users to IPB */
/* By Holbrookau */
/************************************/
require("mainfile.php");
global $dbi, $prefix;
$ipbprefix = "ibf"; // Prefix of your IPB tables - edit if required.
$nukenum = (sql_num_rows(sql_query("select * from ".$prefix."_users",
$dbi))); $sql = "SELECT id FROM $ipbprefix"._members." ORDER BY id
DESC LIMIT 1"; $result = sql_query($sql, $dbi);
list($id) = sql_fetch_row($result, $dbi);
echo "<b>Getting users from phpNuke..</b><br><br>";
$sql = "SELECT uid, uname, email, pass FROM ".$prefix."_users WHERE
uid > 2"; $result = sql_query($sql, $dbi);
if (!$result) {
echo "Error - Could not get members from <b>".$prefix."_users</b>
table";
return;
}
echo "<b>Adding members to IBF..</b><br><br>";
while (list($uid, $uname, $email, $pass) = sql_fetch_row($result,
$dbi)) {
$check_r = sql_query("select count(*) as countck from "
.$ipbprefix."_members
where name = '$uname'", $dbi);
$a = mysql_fetch_array($check_r);
if($a['countck'] <= 0 )
{
$result2 = sql_query("INSERT into ".$ipbprefix."_members
(id,mgroup,
name, password, email) values ('$uid' + ('$id'-2), 3, '$uname',
'$pass', '$email')", $dbi);
if (!$result2) {
echo "Error - Could not add users to <b>".$ipbprefix."_members</b>
table";
return;
} // end check insert result
} // end if check that there are no duplicates //
echo "$uid $uname";
echo "<br>";
} // end insert while loop
echo "<br><b>".$nukenum." phpNuke users have been successfully added
as IPB members.</b><br>Only usernames, email addresses and (encrypted)
passwords have been imported. Please check your
<b>".$ipbprefix."_members</b> table for duplicate users."; ?>
thanks,
webadept-ga |
Clarification of Answer by
webadept-ga
on
08 Oct 2003 15:19 PDT
This should have everything in the right place for printing
<?php
/************************************/
/* Import phpNuke6.0 users to IPB */
/* By Holbrookau */
/************************************/
require("mainfile.php");
global $dbi, $prefix;
$ipbprefix = "ibf"; // Prefix of your IPB tables - edit if required.
$nukenum = (sql_num_rows(sql_query("select * from ".$prefix."_users",
$dbi))); $sql = "SELECT id FROM $ipbprefix"._members." ORDER BY id
DESC LIMIT 1"; $result = sql_query($sql, $dbi);
list($id) = sql_fetch_row($result, $dbi);
echo "<b>Getting users from phpNuke..</b><br><br>";
$sql = "SELECT uid, uname, email, pass FROM ".$prefix."_users WHERE
uid > 2"; $result = sql_query($sql, $dbi);
if (!$result) {
echo "Error - Could not get members from <b>".$prefix."_users</b>
table";
return;
}
echo "<b>Adding members to IBF..</b><br><br>";
while (list($uid, $uname, $email, $pass) = sql_fetch_row($result,
$dbi)) {
$check_r = sql_query("select count(*) as countck from "
.$ipbprefix."_members
where name = '$uname'", $dbi);
$a = mysql_fetch_array($check_r);
if($a['countck'] <= 0 )
{
$result2 = sql_query("INSERT into ".$ipbprefix."_members
(id,mgroup,
name, password, email) values ('$uid' + ('$id'-2), 3, '$uname',
'$pass', '$email')", $dbi);
if (!$result2)
{
echo "Error - Could not add users to <b>".$ipbprefix."_members</b> table";
return;
} // end check insert result
else
{
echo "$uid $uname";
echo "<br>";
} // if all is fine print the names.
} // end if check that there are no duplicates //
} // end insert while loop
echo "<br><b>".$nukenum." phpNuke users have been successfully added
as IPB members.</b><br>Only usernames, email addresses and (encrypted)
passwords have been imported. Please check your
<b>".$ipbprefix."_members</b> table for duplicate users.";
?>
------------
Thanks
webadept-ga
|