导入用户数据,结果发现无法激活.
参考论坛网友的代码,发一下改写的批量激活命令- <?php
- $dbserver ='localhost'; //此处改成数据库服务器地址
- $dbuser ='root';//此处写数据库用户名
- $dbpwd ='1234';//数据库密码
- $dbname ='disucz';//数据库名称
- $charset ='gbk';//此处写字符集gbk或者utf8
- $uc_pre ='pre_ucenter_';//UC表前缀
- $dx_pre ='pre_';//Discuz! X2表前缀
- //此行开始向下不要改动
- set_time_limit(0); //0为无限制
- $connect=mysql_connect($dbserver,$dbuser,$dbpwd) or die("无法连接数据库");
- @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批量导入激活成功";
- ?>
复制代码 将代码保存为一个PHP文件,上传至服务器,直接运行即可.
|