下面说下dedecms整合discuz后会员注册后不用激活的实现,以前做站时,一直在想,dede和dz整合后,会员在网站注册后到论坛能不能不再激活,看着可不舒服,现在总算解决了,闲话不说了,下面进入正题,百度也不让发附件,只有啰嗦点了,呵呵,比较长,分3篇:
1.首先找到dede-〉api-〉uc.php文件
打开uc.php,将内容替换为:
<?php
/**************************二次开发说明**************************************
此模块应用于DEDECMS5.7版本,请替换API文件夹的UC.PHP,替换后,通过DEDE注册的用户,
访问论坛系统可以免激活,实现同时登陆同时退出。
*****************************************版权:**************/
include_once (dirname(__FILE__)."/../include/common.inc.php");
define('IN_DISCUZ', FALSE);
define('UC_CLIENT_VERSION', '1.5.0'); //note UCenter 版本标识
define('UC_CLIENT_RELEASE', '20081031');
define('API_DELETEUSER', 1); //note 用户删除 API 接口开关
define('API_RENAMEUSER', 1); //note 用户改名 API 接口开关
define('API_GETTAG', 1); //note 获取标签 API 接口开关
define('API_SYNLOGIN', 1); //note 同步登录 API 接口开关
define('API_SYNLOGOUT', 1); //note 同步登出 API 接口开关
define('API_UPDATEPW', 1); //note 更改用户密码 开关
define('API_UPDATEBADWORDS', 1); //note 更新关键字列表 开关
define('API_UPDATEHOSTS', 1); //note 更新域名解析缓存 开关
define('API_UPDATEAPPS', 1); //note 更新应用列表 开关
define('API_UPDATECLIENT', 1); //note 更新客户端缓存 开关
define('API_UPDATECREDIT', 1); //note 更新用户积分 开关
define('API_GETCREDITSETTINGS', 1); //note 向 UCenter 提供积分设置 开关
define('API_GETCREDIT', 1); //note 获取用户的某项积分 开关
define('API_UPDATECREDITSETTINGS', 1); //note 更新应用积分设置 开关
define('API_RETURN_SUCCEED', '1');
define('API_RETURN_FAILED', '-1');
define('API_RETURN_FORBIDDEN', '-2');
define('UC_CLIENT_ROOT', DEDEROOT.'/uc_client');
//note 普通的 http 通知方式
if(!defined('IN_UC'))
{
error_reporting(0);
set_magic_quotes_runtime(0);
defined('MAGIC_QUOTES_GPC') || define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
$_DCACHE = $get = $post = array();
$code = @$_GET['code'];
parse_str(_authcode($code, 'DECODE', UC_KEY), $get);
if(MAGIC_QUOTES_GPC)
{
$get = _stripslashes($get);
}
$timestamp = time();
if($timestamp - $get['time'] > 3600) {
exit('Authracation has expiried');
}
if(empty($get)) {
exit('Invalid Request');
}
$action = $get['action'];
require_once UC_CLIENT_ROOT.'/lib/xml.class.php';
$post = xml_unserialize(file_get_contents('php://input'));
if(in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcreditsettings', 'updatecreditsettings')))
{
$uc_note = new uc_note();
exit($uc_note->$get['action']($get, $post));
}else{
exit(API_RETURN_FAILED);
}
//note include 通知方式
} else {
exit('Invalid Request');
}
class uc_note
{
var $dbconfig = '';
var $db = '';
var $appdir = '';
var $tablepre = 'dede_';
function _serialize($arr, $htmlon = 0)
{
if(!function_exists('xml_serialize'))
{
include_once UC_CLIENT_ROOT.'/lib/xml.class.php';
}
return xml_serialize($arr, $htmlon);
}
function uc_note()
{
$this->appdir = DEDEROOT;
$this->dbconfig = DEDEINC.'/common.inc.php';
$this->db = $GLOBALS['dsql'];
$this->tablepre = $GLOBALS['cfg_dbprefix'];
}
function get_uids($uids)
{
include UC_CLIENT_ROOT.'/client.php';
$members = explode(",", $uids);
empty($members) && exit(API_RETURN_FORBIDDEN);
/*$members_username = array();
foreach($members as $id)
{
$row = uc_get_user($id,1);
$members_username[] = $row[1];
}
$comma_temps = implode(",", $members_username);
empty($comma_temps) && exit(API_RETURN_FORBIDDEN);
$comma_uids = array();*/
//$row = $this->db->SetQuery("SELECT mid FROM `dede_member` WHERE userid IN ($comma_temps)");
$this->db->SetQuery("SELECT mid FROM `dede_member` WHERE mid IN ($uids)");
$this->db->Execute();
while($row = $this->db->GetArray())
{
$comma_uids[] = $row['mid'];
}
empty($comma_uids) && exit(API_RETURN_FORBIDDEN);
return implode(",", $comma_uids);
}
function test($get, $post)
{
return API_RETURN_SUCCEED;
}
function deleteuser($get, $post)
{
$uids = $this->get_uids($get['ids']);
!API_DELETEUSER && exit(API_RETURN_FORBIDDEN);