dedecms注冊的會員自動激活discuz論壇
來源:易賢網(wǎng) 閱讀:835 次 日期:2016-06-18 09:13:32
溫馨提示:易賢網(wǎng)小編為您整理了“dedecms注冊的會員自動激活discuz論壇”,方便廣大網(wǎng)友查閱!

dedecms整合discuz同步登錄與退出并且不用激活

弄了一天,問題總算解決了,不過有點投機取巧,下面說下dedecms整合discuz后會員注冊后不用激活的實現(xiàn),以前做站時,一直在想,dede和 dz整合后,會員在網(wǎng)站注冊后到論壇能不能不再激活,看著可不舒服,現(xiàn)在總算解決了,閑話不說了,下面進入正題,百度也不讓發(fā)附件,只有啰嗦點了,呵呵, 比較長,分3篇:

1.首先找到dede-〉api-〉uc.php文件

打開uc.php,將內(nèi)容替換為:

<?php

/**************************二次開發(fā)說明**************************************

此模塊應用于dedecms5.6版本,請?zhí)鎿Qapi文件夾的uc.php,替換后,通過dede注冊的用戶,

訪問論壇系統(tǒng)可以免激活,實現(xiàn)同時登陸同時退出。

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 接口開關(guān)

define('api_renameuser', 1); //note 用戶改名 api 接口開關(guān)

define('api_gettag', 1); //note 獲取標簽 api 接口開關(guān)

define('api_synlogin', 1); //note 同步登錄 api 接口開關(guān)

define('api_synlogout', 1); //note 同步登出 api 接口開關(guān)

define('api_updatepw', 1); //note 更改用戶密碼 開關(guān)

define('api_updatebadwords', 1); //note 更新關(guān)鍵字列表 開關(guān)

define('api_updatehosts', 1); //note 更新域名解析緩存 開關(guān)

define('api_updateapps', 1); //note 更新應用列表 開關(guān)

define('api_updateclient', 1); //note 更新客戶端緩存 開關(guān)

define('api_updatecredit', 1); //note 更新用戶積分 開關(guān)

define('api_getcreditsettings', 1); //note 向 ucenter 提供積分設置 開關(guān)

define('api_getcredit', 1); //note 獲取用戶的某項積分 開關(guān)

define('api_updatecreditsettings', 1); //note 更新應用積分設置 開關(guān)

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);

//note 用戶刪除 api 接口

$rs = $this->db->executenonequery2(delete from `dede_member` where mid in ($uids) and matt<>10 limit 1);

if($rs > 0)

{

$this->db->executenonequery(delete from `dede_member_tj` where mid in ($uids) limit 1);

$this->db->executenonequery(delete from `dede_member_space` where mid in ($uids) limit 1);

$this->db->executenonequery(delete from `dede_member_company` where mid in ($uids) limit 1);

$this->db->executenonequery(delete from `dede_member_person` where mid in ($uids) limit 1);

//刪除用戶相關(guān)數(shù)據(jù)

$this->db->executenonequery(delete from `dede_member_stow` where mid in ($uids) );

$this->db->executenonequery(delete from `dede_member_flink` where mid in ($uids) );

$this->db->executenonequery(delete from `dede_member_guestbook` where mid in ($uids) );

$this->db->executenonequery(delete from `dede_member_operation` where mid in ($uids) );

$this->db->executenonequery(delete from `dede_member_pms` where toid in ($uids) or fromid in ($uids) );

$this->db->executenonequery(delete from `dede_member_friends` where mid in ($uids) or fid in ($uids) );

$this->db->executenonequery(delete from `dede_member_vhistory` where mid in ($uids) or vid in ($uids) );

$this->db->executenonequery(delete from `dede_feedback` where mid in ($uids) );

$this->db->executenonequery(update `dede_archives` set mid='0' where mid in ($uids));

}

else

{

exit(api_return_forbidden);

}

return api_return_succeed;

}

function renameuser($get, $post)

{

$uids = $this->get_uids($get['ids']);

$usernameold = $get['oldusername'];

$usernamenew = $get['newusername'];

if(!api_renameuser)

{

return api_return_forbidden;

}

//note 獲取標簽 api 接口

$rs = $this->db->executenonequery2(update `dede_member` set userid='$usernamenew' where userid='$usernamenew' and matt<>10 limit 1);

if($rs > 0)

{

$this->db->executenonequery(update `dede_archives` set writer='$usernamenew' where writer='$usernamenew');

$this->db->executenonequery(update `dede_member_pms` set floginid=replace(floginid, 't$usernameold', 't$usernamenew'),tologinid=replace(tologinid, 't$usernameold', 't$usernamenew'));

$row = $this->db->getone(show table status);

$db_tables = $row['name']; unset($row);

if(in_array($this->tablepre.'guestbook',$db_tables))

{

$this->db->executenonequery(update `dede_guestbook` set uname='$usernamenew' where uname='$usernamenew');

}

if(in_array($this->tablepre.'story_books',$db_tables))

{

$this->db->executenonequery(update `dede_story_books` set author='$usernamenew' where author='$usernamenew');

}

if(in_array($this->tablepre.'groups',$db_tables))

{

$this->db->executenonequery(update `dede_groups` set creater='$usernamenew' where creater='$usernamenew');

$this->db->executenonequery(update `dede_group_threads` set author='$usernamenew' where author='$usernamenew');

$this->db->executenonequery(update `dede_group_user` set username='$usernamenew' where username='$usernamenew');

$this->db->executenonequery(update `dede_group_posts` set author='$usernamenew' where author='$usernamenew');

$this->db->executenonequery(update `dede_group_guestbook` set uname='$usernamenew' where uname='$usernamenew');

$this->db->executenonequery(update `dede_groups` set ismaster=replace(ismaster, 't$usernameold', 't$usernamenew'));

}

return api_return_succeed;

}

else

{

return api_return_forbidden;

}

}

function gettag($get, $post)

{

$name = $get['id'];

if(!api_gettag)

{

return api_return_forbidden;

}

//note 獲取標簽 api 接口

$name = trim($name);

if(empty($name) || !preg_match('/^([x7f-xff_-]|w|s)+$/', $name) || strlen($name) > 20)

{

return api_return_failed;

}

$row = $this->db->getone(select `total`,`id` from `dede_tagindex` where `tag`='$name');

if(!is_array($row))

{

return api_return_failed;

}

$tpp = $row['total'] > 10 ? 10 : $row['total'];

$ids = array();

$this->db->setquery(select aid from `dede_taglist` where `tid`='$row[id]' and arcrank>-1);

$this->db->execute();

while($row = $this->db->getarray())

{

$ids[] = $row['aid'];

}

if(empty($ids))

{

return api_return_failed;

}

$aids = implode(,, $ids);

include_once dedeinc.'/channelunit.func.php';

$archives_list = array();

$this->db->setquery(select arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath

from `dede_archives` arc left join `dede_arctype` tp on arc.typeid=tp.id where arc.id in($aids) order by id desc limit $tpp);

$this->db->execute();

while($row = $this->db->getarray())

{

$row['url'] = getfileurl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],$row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']);

$row['url'] = !ereg('http:',$row['url']) ? $globals['cfg_basehost'].$row['url'] : $row['url'];

if(!empty($row['url']))

{

$archives_list[] = array('title' => $row['title'],'writer' => $row['writer'],'pubdate' => $row['pubdate'],'url' => $row['url']);

}

}

$return = array($name, $archives_list);

return $this->_serialize($return, 1);

}

function synlogin($get, $post)

{

$uid = $get['uid'];

$username = $get['username'];

if(!api_synlogin)

{

return api_return_forbidden;

}

//note 同步登錄 api 接口

header('p3p: cp=cura adma deva psao psdo our bus uni pur int dem sta pre com nav otc noi dsp cor');

$result = $this->db->getone(select mid,pwd from `dede_member` where `userid` like '$username' and matt<>10);

if(is_array($result))

{

include_once dedeinc.'/memberlogin.class.php';

$cfg_ml = new memberlogin(86400);

$cfg_ml->putlogininfo($result['mid']);

}

else

{

//如果沒有激活,則自動添加該用戶到數(shù)據(jù)庫,并設置已激活狀態(tài)的cookie

//會員的默認金幣

$dfscores = 0;

$dfmoney = 0;

$dfrank = $this->db->getone(select money,scores from `dede_arcrank` where rank='10' );

if(is_array($dfrank))

{

$dfmoney = $dfrank['money'];

$dfscores = $dfrank['scores'];

}

$jointime = time();

$logintime = time();

$joinip = $get['regip'];

$loginip = $get['regip'];

$pwd = $get['password'];

$spacesta = ($cfg_mb_spacesta < 0 ? $cfg_mb_spacesta : 0);

$mtype='個人';

$email=$get['email'];

$inquery = insert into `dede_member` (`mtype` ,`userid` ,`pwd` ,`uname` ,`sex` ,`rank` ,`money` ,`email` ,`scores` ,

`matt`, `spacesta` ,`face`,`safequestion`,`safeanswer` ,`jointime` ,`joinip` ,`logintime` ,`loginip` )

values ('$mtype','$username','$pwd','$username','保密','10','$dfmoney','$email','$dfscores',

'0','$spacesta','','','','$jointime','$joinip','$logintime','$loginip'); ;

if($this->db->executenonequery($inquery))

{

$mid = $this->db->getlastid();

//寫入默認會員詳細資料

$space='person';

//寫入默認統(tǒng)計數(shù)據(jù)

$membertjquery = insert into `dede_member_tj` (`mid`,`article`,`album`,`archives`,`homecount`,`pagecount`,`feedback`,`friend`,`stow`)

values ('$mid','0','0','0','0','0','0','0','0'); ;

$this->db->executenonequery($membertjquery);

//寫入默認空間配置數(shù)據(jù)

$spacequery = insert into `dede_member_space`(`mid` ,`pagesize` ,`matt` ,`spacename` ,`spacelogo` ,`spacestyle`, `sign` ,`spacenews`)

values('$mid','10','0','$username的空間','','$space','',''); ;

$this->db->executenonequery($spacequery);

//寫入其它默認數(shù)據(jù)

$this->db->executenonequery(insert into `dede_member_flink`(mid,title,url) values('$mid','織夢內(nèi)容管理系統(tǒng)','http://www.dedecms.com'); );

include_once dedeinc.'/membermodel.cls.php';

$membermodel = new membermodel($mtype);

$modid=$membermodel->modid;

$modelform = $this->db->getone(select * from dede_member_model where id='$modid' );

$this->db->executenonequery(insert into `{$membermodel->table}` (`mid`) values ('$mid'););

//----------------------------------------------

//模擬登錄

//---------------------------

include_once dedeinc.'/memberlogin.class.php';

$cfg_ml = new memberlogin(7*3600);

$cfg_ml->putlogininfo($mid);

}

}

}

function synlogout($get, $post)

{

if(!api_synlogout)

{

return api_return_forbidden;

}

//note 同步登出 api 接口

header('p3p: cp=cura adma deva psao psdo our bus uni pur int dem sta pre com nav otc noi dsp cor');

include_once dedeinc.'/memberlogin.class.php';

$cfg_ml = new memberlogin();

$cfg_ml->exitcookie();

}

function updatepw($get, $post)

{

if(!api_updatepw)

{

return api_return_forbidden;

}

$username = $get['username'];

$password = $get['password'];

//note 修改密碼 api 接口

$newpw = md5($password);

$this->db->executenonequery(update `dede_member` set `pwd`='$newpw' where `userid`='$username');

return api_return_succeed;

}

function updatebadwords($get, $post)

{

if(!api_updatebadwords)

{

return api_return_forbidden;

}

$row = $this->db->getone(select `value` from `dede_sysconfig` where `varname`='cfg_replacestr');

$badwords = isset($row['value']) ? explode(,, $row['value']) : array();

if(is_array($post))

{

foreach($post as $k => $v)

{

if(in_array($v['find'],$badwords)) continue;

$badwords[] = $v['find'];

}

}

$badwords_comma = !empty($badwords) ? implode(,, $badwords) : '';

$this->db->executenonequery(update `dede_sysconfig` set `value`='$badwords_comma' where `varname`='cfg_replacestr');

$cachefile = dededata.'/config.cache.inc.php';

if(!is_writeable($cachefile))

{

return api_return_forbidden;

}

$fp = fopen($cachefile, 'w');

$this->db->setquery(select `varname`,`type`,`value`,`groupid` from `dede_sysconfig` order by aid asc );

$this->db->execute();

$s = '<?php'.rn;

while($row = $this->db->getarray())

{

$s .= '$'.$row['varname'].' = '.($row['type']=='number' ? $row['value'] : '.str_replace(','',$row['value']).').;rn;

}

$s .= '?>';

fwrite($fp, $s);

fclose($fp);

return api_return_succeed;

}

function updatehosts($get, $post)

{

if(!api_updatehosts)

{

return api_return_forbidden;

}

//note 理新host緩存 api 接口

$cachefile = uc_client_root.'/data/cache/hosts.php';

$fp = fopen($cachefile, 'w');

$s = <?phprn;

$s .= '$_cache['hosts'] = '.var_export($post, true).;rn;

fwrite($fp, $s);

fclose($fp);

return api_return_succeed;

}

function updateapps($get, $post)

{

if(!api_updateapps)

{

return api_return_forbidden;

}

$uc_api = $post['uc_api'];

//note 寫 app 緩存文件

$cachefile = uc_client_root.'/data/cache/apps.php';

$fp = fopen($cachefile, 'w');

$s = <?phprn;

$s .= '$_cache['apps'] = '.var_export($post, true).;rn;

fwrite($fp, $s);

fclose($fp);

return api_return_succeed;

}

function updateclient($get, $post)

{

if(!api_updateclient)

{

return api_return_forbidden;

}

$cachefile = uc_client_root.'/data/cache/settings.php';

$fp = fopen($cachefile, 'w');

$s = '<?php'.rn;

$s .= '$_cache['settings'] = '.var_export($post, true).;rn;

fwrite($fp, $s);

fclose($fp);

return api_return_succeed;

}

function updatecredit($get, $post)

{

if(!api_updatecredit)

{

return api_return_forbidden;

}

/*

note 更新積分

discuz 默認8個積分表達,而dedecms只有一個積分字段,scores.注意money不能做積分來用.

extcredits1 extcredits2 extcredits3 extcredits4 extcredits5 extcredits6 extcredits7 extcredits8

*/

$credit = intval($get['credit']);

$fileds = $credit > 1 ? 'money' : 'scores';

$amount = $get['amount'];

$uid = $get['uid'];

include uc_client_root.'/client.php';

$data = uc_get_user($uid,1);

$username = $data[1];

$result = $this->db->getone(select mid from `dede_member` where userid='$username');

if(is_array($result))

{

$this->db->executenonequery(update `dede_member` set `$fileds`=`$fileds`+'$amount' where mid='$result[mid]');

}

return api_return_succeed;

}

function getcredit($get, $post)

{

if(!api_getcredit)

{

return api_return_forbidden;

}

include uc_client_root.'/client.php';

$data = uc_get_user($uid,1);

$username = $data[1];

$credit = intval($get['credit']);

$fileds = $credit > 1 ? 'money' : 'scores';

$result = $this->db->getone(select `$fileds` as credit from `dede_member` where userid='$username');

echo is_array($result) ? $result['credit'] : 0;

}

function getcreditsettings($get, $post)

{

if(!api_getcreditsettings)

{

return api_return_forbidden;

}

//這里支持dedecms積分,金幣設置

$credits[1] = array(strip_tags('積分'), '分');

$credits[2] = array(strip_tags('金幣'), '枚');

return $this->_serialize($credits);

}

function updatecreditsettings($get, $post)

{

if(!api_updatecreditsettings)

{

return api_return_forbidden;

}

$credit = $get['credit'];

$outextcredits = array();

if($credit && is_array($credit)) {

foreach($credit as $appid => $credititems) {

foreach($credititems as $value) {

if($value['appiddesc']!=uc_appid) continue;

$outextcredits[$appid][] = array(

'appiddesc' => $value['appiddesc'],

'creditdesc' => $value['creditdesc'],

'creditsrc' => $value['creditsrc'],

'title' => $value['title'],

'unit' => $value['unit'],

'ratiosrc' => $value['ratiosrc'],

'ratiodesc' => $value['ratiodesc'],

'ratio' => $value['ratio']

);

}

}

}

$_cache = <?php !defined('uc_api') && exit(403 forbidden!);n.'$_cache['credit'] = unserialize('.addslashes(serialize($outextcredits)).');'.rn.'?>';

$fp = @fopen(dededata.'/credits.inc.php', 'w');

@fwrite($fp, $_cache);

@fclose($fp);

return api_return_succeed;

}

}

function _authcode($string, $operation = 'decode', $key = '', $expiry = 0) {

$ckey_length = 4;

$key = md5($key ? $key : uc_key);

$keya = md5(substr($key, 0, 16));

$keyb = md5(substr($key, 16, 16));

$keyc = $ckey_length ? ($operation == 'decode' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';

$cryptkey = $keya.md5($keya.$keyc);

$key_length = strlen($cryptkey);

$string = $operation == 'decode' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;

$string_length = strlen($string);

$result = '';

$box = range(0, 255);

$rndkey = array();

for($i = 0; $i <= 255; $i++) {

$rndkey[$i] = ord($cryptkey[$i % $key_length]);

}

for($j = $i = 0; $i < 256; $i++) {

$j = ($j + $box[$i] + $rndkey[$i]) % 256;

$tmp = $box[$i];

$box[$i] = $box[$j];

$box[$j] = $tmp;

}

for($a = $j = $i = 0; $i < $string_length; $i++) {

$a = ($a + 1) % 256;

$j = ($j + $box[$a]) % 256;

$tmp = $box[$a];

$box[$a] = $box[$j];

$box[$j] = $tmp;

$result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));

}

if($operation == 'decode') {

if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {

return substr($result, 26);

} else {

return '';

}

} else {

return $keyc.str_replace('=', '', base64_encode($result));

}

}

function _stripslashes($string) {

if(is_array($string)) {

foreach($string as $key => $val) {

$string[$key] = _stripslashes($val);

}

} else {

$string = stripslashes($string);

}

return $string;

}

?>

更多信息請查看CMS教程
易賢網(wǎng)手機網(wǎng)站地址:dedecms注冊的會員自動激活discuz論壇
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇剩?/div>
相關(guān)閱讀CMS教程

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)