UCENTER 设置),等于通过 UC 注册的账号,仍必须在 DX2.5 登录一次,才能自动激活账号,这样其它基于 UC 的其它应用,才能实现异步登录。
以下方法解决第三方应用登录,同时异步登录 DX2.5,,已在 DX2.5+UC1.6+开发的第三方应用中测试通过。
非官方解决方法:
修改 dx2.5 目录下的 api/uc.php
找到以下代码
- 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']);
- if(($member = getuserbyuid($uid, 1))) {
- dsetcookie('auth', authcode("$member[password] $member[uid]", 'ENCODE'), $cookietime);
- }
- }
改成:
- 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']);
- if(($member = getuserbyuid($uid, 1))) {
- dsetcookie('auth', authcode("$member[password] $member[uid]", 'ENCODE'), $cookietime);
- }
- /**以下代码是新添加**/
- else{
- $init_arr = explode(',', $_G['setting']['initcredits']);
- $groupid = $_G['setting']['regverify'] ? 8 : $_G['setting']['newusergroupid'];
- C::t('common_member')->insert($uid,
$get['username'], md5(random(10)), $get['email'], $_G['clientip'],
$groupid, $init_arr); -
C::t('common_member_status')->update($uid, array('lastip' =>
$_G['clientip'], 'lastvisit' =>TIMESTAMP, 'lastactivity' =>
TIMESTAMP)); - if(($member = getuserbyuid($uid, 1))) {
- dsetcookie('auth', authcode("$member[password] $member[uid]", 'ENCODE'), $cookietime);
- }
- }
- /**到这里新增代码结束**/
- }
如果要符合 DX2.5 后台的自动激活选项,要改成这样:
- 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']);
- if(($member = getuserbyuid($uid, 1))) {
- dsetcookie('auth', authcode("$member[password] $member[uid]", 'ENCODE'), $cookietime);
- }
- else{
- if($_G['setting']['fastactivation']){
- $init_arr = explode(',', $_G['setting']['initcredits']);
- $groupid = $_G['setting']['regverify'] ? 8 : $_G['setting']['newusergroupid'];
-
C::t('common_member')->insert($uid, $get['username'],
md5(random(10)), $get['email'], $_G['clientip'], $groupid, $init_arr); -
C::t('common_member_status')->update($uid, array('lastip' =>
$_G['clientip'], 'lastvisit' =>TIMESTAMP, 'lastactivity' =>
TIMESTAMP)); - if(($member = getuserbyuid($uid, 1))) {
- dsetcookie('auth', authcode("$member[password] $member[uid]", 'ENCODE'), $cookietime);
- }
- }
- }
- }
只是简单实现登录,不保证有没有其它的风险存在。慎用。后果自负。