整合程序注册时自动激活DZX会员 for discuz!X 1.5

实现自动激活DZX会员,专门针对在其它整合程序下注册会员时dzx会员需激活进行处理。

打开discuz!x下api/uc.php文件:

1、查找:

require DISCUZ_ROOT.'./config/config_ucenter.php';

替换为:

loaducenter();

2、查找:

function synlogin($get, $post) {
global $_G;

if(!API_SYNLOGIN) {
return API_RETURN_FORBIDDEN;
}

header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE  COM NAV OTC NOI DSP COR"');

$cookietime = 31536000;
$uid = intval($get['uid']);
$query =  DB::query("SELECT uid, username, password FROM ".DB::table('common_member')."  WHERE uid='$uid'");
if($member = DB::fetch($query))  {
dsetcookie('auth', authcode("$member[password]\t$member[uid]",  'ENCODE'), $cookietime);
}
}

替换为:

	//Start 完美自动激活DZX会员
	function synlogin($get, $post) {
		global $_G;
		
		if(!API_SYNLOGIN) {
			return API_RETURN_FORBIDDEN;
		}
		
		header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
		
		$cookietime = 31536000;
		$uid = intval($get['uid']);
		$query = DB::query("SELECT uid, username, password FROM ".DB::table('common_member')." WHERE uid='$uid'");
		if($member = DB::fetch($query)) {
			dsetcookie('auth', authcode("$member[password]\t$member[uid]", 'ENCODE'), $cookietime);
		}else{		
			if($userdata = uc_get_user($uid, 1)) {
				list($uid, $username, $email) = $userdata;
				$password = md5(time().rand(100000, 999999));
				$ip = $_G['clientip'];
				$time = time();			
				
				$userdata = array(
					'uid' => $uid,
					'username' => $username,
					'password' => $password,
					'email' => $email,
					'adminid' => 0,
					'groupid' => 10,
					'regdate' => $time,
					'credits' => 0,
					'timeoffset' => 9999
				);
				DB::insert('common_member', $userdata);
				
				$status_data = array(
					'uid' => $uid,
					'regip' => $ip,
					'lastip' => $ip,
					'lastvisit' => $time,
					'lastactivity' => $time,
					'lastpost' => 0,
					'lastsendmail' => 0,
				);
				DB::insert('common_member_status', $status_data);
				DB::insert('common_member_profile', array('uid' => $uid));
				DB::insert('common_member_field_forum', array('uid' => $uid));
				DB::insert('common_member_field_home', array('uid' => $uid));
				DB::insert('common_member_count', array('uid' => $uid)); 
				DB::insert('common_setting', array('skey' => 'lastmember', 'svalue' => $username), false, true);
			
				dsetcookie('auth', authcode("$password\t$uid", 'ENCODE'), $cookietime);
			}
		}
		
	}
	//End 完美自动激活DZX会员

3 Replies to “整合程序注册时自动激活DZX会员 for discuz!X 1.5”

Leave a Reply