經(jīng)常在完成一次DZ與UC的對(duì)接之后,會(huì)出現(xiàn)這樣的問(wèn)題,如果不解決,就會(huì)出現(xiàn)所有老用戶需要重新激活,而且需要驗(yàn)證郵箱的問(wèn)題,下面給出方案解決。
將下面代碼復(fù)制到一個(gè)php中,并在瀏覽器輸入地址執(zhí)行
<?php $dbserver =’localhost’; //此處改成數(shù)據(jù)庫(kù)服務(wù)器地址 $dbuser =’root’;//此處寫(xiě)數(shù)據(jù)庫(kù)用戶名 $dbpwd =’1234′;//數(shù)據(jù)庫(kù)密碼 $dbname =’disucz’;//數(shù)據(jù)庫(kù)名稱 $charset =’gbk’;//此處寫(xiě)字符集gbk或者utf8 $uc_pre =’pre_ucenter_’;//UC表前綴 $dx_pre =’pre_’;//Discuz! X2表前綴 //此行開(kāi)始向下不要改動(dòng) set_time_limit(0); //0為無(wú)限制 $connect=mysql_connect($dbserver,$dbuser,$dbpwd) or die(“無(wú)法連接數(shù)據(jù)庫(kù)”); @mysql_select_db($dbname,$connect); mysql_query(“set names $charset”); $query = mysql_query(“SELECT * FROM `{$uc_pre}members` WHERE `uid` not in(select `uid` from `{$dx_pre}common_member`) “,$connect); while($user = mysql_fetch_array($query)) { $password=$user[password]; mysql_query(” replace INTO `{$dx_pre}common_member` (uid,username,password,adminid,groupid,regdate,email) VALUES (‘$user[uid]’, ‘$user[username]’, ‘$password’,’0′,’10’,’$user[regdate]’,’$user[email]’) “); mysql_query(” replace INTO `{$dx_pre}common_member_field_forum` (uid) VALUES (‘$user[uid]’)”); mysql_query(” replace INTO `{$dx_pre}common_member_field_home` (uid) VALUES (‘$user[uid]’)”); mysql_query(” replace INTO `{$dx_pre}common_member_count` (uid) VALUES (‘$user[uid]’)”); mysql_query(” replace INTO `{$dx_pre}common_member_profile` (uid) VALUES (‘$user[uid]’)”); mysql_query(” replace INTO `{$dx_pre}common_member_status` (uid) VALUES (‘$user[uid]’)”); } echo “已從UC批量導(dǎo)入激活成功”; ?>
注釋:連接到數(shù)據(jù)庫(kù)后,PHP會(huì)比對(duì)UC和DZ用戶表的數(shù)據(jù),發(fā)現(xiàn)不存在于DZ但是存在于UC的用戶,就會(huì)把用戶導(dǎo)入到DZ,但是這一注冊(cè)不會(huì)設(shè)置其他內(nèi)容,比如用戶填寫(xiě)的詳細(xì)信息,由于以前是存儲(chǔ)在DZ數(shù)據(jù)庫(kù)中,所以還是丟失了
這樣子用戶已經(jīng)全部導(dǎo)入,用戶數(shù)也恢復(fù)了正常
下一步,將用戶的郵箱驗(yàn)證全部設(shè)置為已驗(yàn)證
數(shù)據(jù)庫(kù)執(zhí)行:
update pre_common_menber ste emailstatus=“1”;
注釋:這是更新數(shù)據(jù)庫(kù)中emailstatus字段,1為驗(yàn)證 pre記得改為你的論壇的前綴