function DoMerge() { $start = max(0, (int) $this->Get['start']); $limit = 500; $ucenter = jconf::get('ucenter'); if (!$ucenter['enable'] || !$this->Get['confirm'] || 'mysql' != $ucenter['uc_connect']) { $this->Messager("你的配置不正确,或者已经进行过用户数据整合了", 'admin.php?mod=ucenter&code=ucenter'); } include_once ROOT_PATH . './api/uc_api_db.php'; $db = new JSG_UC_API_DB(); $db->connect($this->Config['db_host'], $this->Config['db_user'], $this->Config['db_pass'], $this->Config['db_name'], $this->Config['charset'], $this->Config['db_persist'], $this->Config['db_table_prefix']); if (!$start) { if (get_param('new_merge')) { $db->query("update " . TABLE_PREFIX . "members set `ucuid`=0 where `ucuid`!=0"); } else { $db->query("update " . TABLE_PREFIX . "members set `ucuid`=0 where `ucuid`<0"); } } $query = $db->query("select * from " . TABLE_PREFIX . "members where ucuid=0 limit {$limit}"); if ($db->num_rows($query) < 1) { $this->Messager("用户数据合并成功", 'admin.php?mod=ucenter&code=ucenter'); } $uc_db = new JSG_UC_API_DB(); $uc_db->connect($ucenter['uc_db_host'], $ucenter['uc_db_user'], $ucenter['uc_db_password'], $ucenter['uc_db_name'], $ucenter['uc_db_charset'], 0, $ucenter['uc_db_table_prefix']); while (false != ($data = $db->fetch_array($query))) { $ucuid = -1; $db->query("update `" . TABLE_PREFIX . "members` set `ucuid`='{$ucuid}' where `uid`='{$data['uid']}'"); if ($data['salt']) { $salt = $data['salt']; $password = $data['password']; } else { $salt = rand(100000, 999999); $password = md5($data['password'] . $salt); } $data['username'] = addslashes($data['username']); $data['nickname'] = addslashes($data['nickname']); $uc_user = $uc_db->fetch_first("SELECT * FROM {$ucenter['uc_db_table_prefix']}members WHERE username='******'nickname']}'"); if (!$uc_user) { $uc_db->query("INSERT LOW_PRIORITY INTO {$ucenter['uc_db_table_prefix']}members SET username='******'nickname']}', `password`='{$password}',email='{$data['email']}', regip='{$data['regip']}', regdate='{$data['regdate']}', salt='{$salt}'", 'SILENT'); $ucuid = $uc_db->insert_id(); $uc_db->query("INSERT LOW_PRIORITY INTO {$ucenter['uc_db_table_prefix']}memberfields SET uid='{$ucuid}'", 'SILENT'); } else { $ucuid = $uc_user['uid']; } $db->query("update `" . TABLE_PREFIX . "members` set `ucuid`='{$ucuid}' where `uid`='{$data['uid']}'"); } $db->close(); $uc_db->close(); $next = $start + $limit; $this->Messager("[{$start}-{$next}]正在进行用户数据的合并中,请稍候……", 'admin.php?mod=ucenter&code=merge&confirm=1&start=' . $next); }