/** * 将当前系统的会员同步给UCenter * 规则 * 1. 保证 easethink 中有的会员 ucenter 中必需存在,并同步密码 * 2. 重名会员以 easethink 中的会员资料为准,并将原ucenter中的会员资料记录到log中 * 3. ucenter中存在的会员。easethink中如不存在暂不处理。 */ private function import_user() { if (file_exists(APP_ROOT_PATH . "public/uc_config.php")) { require_once APP_ROOT_PATH . "public/uc_config.php"; $ucdb = new mysql_db(UC_DBHOST, UC_DBUSER, UC_DBPW, UC_DBNAME, UC_DBCHARSET); $result = array('status' => 1, 'msg' => ''); /*$uc_user = $ucdb->getAll("select * from ".UC_DBTABLEPRE."members"); $et_user = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user"); print_r($uc_user); print_r($et_user); exit;*/ require_once APP_ROOT_PATH . "system/utils/logger.php"; $query = $GLOBALS['db']->query("SELECT * FROM " . DB_PREFIX . "user ORDER BY `id` ASC"); while ($data = $GLOBALS['db']->fetch_array($query)) { if (UC_CHARSET != 'utf-8') { $data['user_name'] = iconv("utf-8", UC_CHARSET, $data['user_name']); $data['user_pwd'] = iconv("utf-8", UC_CHARSET, $data['user_pwd']); $data['email'] = iconv("utf-8", UC_CHARSET, $data['email']); } $salt = rand(100000, 999999); $password = md5($data['user_pwd'] . $salt); $data['user_name'] = addslashes($data['user_name']); $uc_userinfo = $ucdb->getRow("SELECT * FROM " . UC_DBTABLEPRE . "members WHERE `username`='" . $data['user_name'] . "'"); if (!$uc_userinfo) { $ucdb->query("INSERT INTO " . UC_DBTABLEPRE . "members SET username='******'user_name'] . "', password='******', email='" . $data['email'] . "', regdate='" . $data['create_time'] . "', salt='{$salt}'", 'SILENT'); $integrate_id = intval($ucdb->insert_id()); $GLOBALS['db']->query("update " . DB_PREFIX . "user set integrate_id = " . $integrate_id . " where id = " . $data['id']); } else { //存在同名会员 //开始记录原系统同的同名数据 $data_str = implode("|", $data); logger::record($data_str); logger::save(); $GLOBALS['db']->query("update " . DB_PREFIX . "user set integrate_id = " . $uc_userinfo['uid'] . ",user_pwd = '' where id = " . $data['id']); //清空原密码,等待同步登录时与ucenter同步 } } unset($query); } return $result; }
public function install($config_seralized) { $config = unserialize($config_seralized); if ($config['IS_LATIN1'] == 2) { $config['DB_CHARSET'] = 'latin1'; } if (!@mysql_pconnect($config['DB_HOST'], $config['DB_USER'], $config['DB_PASS'])) { $result['status'] = 0; $result['msg'] = '无法连接数据库'; return $result; } else { $pwdb = new mysql_db($config['DB_HOST'], $config['DB_USER'], $config['DB_PASS'], $config['DB_NAME'], $config['DB_CHARSET']); //开始将easethink的会员导入到pw中 $query = $GLOBALS['db']->query("SELECT * FROM " . DB_PREFIX . "user ORDER BY `id` ASC"); while ($data = $GLOBALS['db']->fetch_array($query)) { $pw_userinfo = $pwdb->getRow("SELECT * FROM " . $config['PREFIX'] . "members WHERE `username`='" . $data['user_name'] . "'"); if (!$pw_userinfo) { $pwdb->query("INSERT INTO " . $config['PREFIX'] . "members SET username='******'user_name'] . "', password='******'user_pwd'] . "', email='" . $data['email'] . "', regdate='" . $data['create_time'] . "'", 'SILENT'); $integrate_id = intval($pwdb->insert_id()); $GLOBALS['db']->query("update " . DB_PREFIX . "user set integrate_id = " . $integrate_id . " where id = " . $data['id']); } else { //存在同名会员 $data['user_name'] = $data['user_name'] . $config['SUFFIX']; $pwdb->query("INSERT INTO " . $config['PREFIX'] . "members SET username='******'user_name'] . "', password='******'user_pwd'] . "', email='" . $data['email'] . "', regdate='" . $data['create_time'] . "'", 'SILENT'); $integrate_id = intval($pwdb->insert_id()); $GLOBALS['db']->query("update " . DB_PREFIX . "user set integrate_id = " . $integrate_id . " where id = " . $data['id']); } /* 更新memberdata表 */ $sql = 'INSERT INTO ' . $config['PREFIX'] . 'memberdata set uid = ' . $integrate_id; $pwdb->query($sql, "SILENT"); } unset($query); $result['status'] = 1; return $result; } }