<script type="text/javascript"><!--
google_ad_client = "pub-0241434510974184";
/* auto-http.cn 右边 ,468x60 */
google_ad_slot = "0902256228";
google_ad_width = 468;
google_ad_height = 60;
// --></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
这个是Discuz!注册的接口代码.
注册的时候,页面可以不用跳转到Discuz!.
修改如下配置:
1.代码第5行.获取Discuz!的密钥.
路径: /Discuz!/forumdata/cache/cache_settings.php
// 密钥文件
$authkey = 'd99eb99UFBPcE0mv';//论坛的 authkey
2.代码7~13行,修改传递用的用户名,密码.
$array = array (
'action' => 'register', // login,register
'username' => 'username',
'password' => '000000',
'questionid' => '',
'answer' => '',);
3.140~141行.获取登录状态
登录状态:
1.登录成功,插入新用户
0.用户已经注册过了,或者注册失败.
$returnFlg = implode('', file('http://127.0.0.1/bbs/api/userprofile.php?sign='.$sign.'&'.$urlstr));
echo $returnFlg ;
<?

//Discuz! orumdatacachecache_settings.php
$authkey='ece1b5LV9brA5wXR';//论坛的authkey

$array=array(
'action'=>'register',//login,register
'username'=>'usename',
'password'=>'000000',
'questionid'=>'',
'answer'=>'',
);

$sign=$url='';
foreach($arrayas$key=>$val){
$sign.='&'.$key.'='.$val;
$urlstr.=$key.'='.rawurlencode($val).'&';
}

$sign=md5($sign.$authkey);

/////////////////////////////////////////////////////////////////////////////////
/**
*Passport加密函数
*
*@paramstring等待加密的原字串
*@paramstring私有密匙(用于解密和加密)
*
*@returnstring原字串经过私有密匙加密后的结果
*/
functionpassport_encrypt($txt,$key){

//使用随机数发生器产生0~32000的值并MD5()
srand((double)microtime()*1000000);
$encrypt_key=md5(rand(0,32000));

//变量初始化
$ctr=0;
$tmp='';

//for循环,$i为从0开始,到小于$txt字串长度的整数
for($i=0;$i<strlen($txt);$i++){
//如果$ctr=$encrypt_key的长度,则$ctr清零
$ctr=$ctr==strlen($encrypt_key)?0:$ctr;
//$tmp字串在末尾增加两位,其第一位内容为$encrypt_key的第$ctr位,
//第二位内容为$txt的第$i位与$encrypt_key的$ctr位取异或。然后$ctr=$ctr+1
$tmp.=$encrypt_key[$ctr].($txt[$i]^$encrypt_key[$ctr++]);
}

//返回结果,结果为passport_key()函数返回值的base64编码结果
returnbase64_encode(passport_key($tmp,$key));

}

/**
*Passport解密函数
*
*@paramstring加密后的字串
*@paramstring私有密匙(用于解密和加密)
*
*@returnstring字串经过私有密匙解密后的结果
*/
functionpassport_decrypt($txt,$key){

//$txt的结果为加密后的字串经过base64解码,然后与私有密匙一起,
//经过passport_key()函数处理后的返回值
$txt=passport_key(base64_decode($txt),$key);

//变量初始化
$tmp='';

//for循环,$i为从0开始,到小于$txt字串长度的整数
for($i=0;$i<strlen($txt);$i++){
//$tmp字串在末尾增加一位,其内容为$txt的第$i位,
//与$txt的第$i+1位取异或。然后$i=$i+1
$tmp.=$txt[$i]^$txt[++$i];
}

//返回$tmp的值作为结果
return$tmp;

}

/**
*Passport密匙处理函数
*
*@paramstring待加密或待解密的字串
*@paramstring私有密匙(用于解密和加密)
*
*@returnstring处理后的密匙
*/
functionpassport_key($txt,$encrypt_key){

//将$encrypt_key赋为$encrypt_key经md5()后的值
$encrypt_key=md5($encrypt_key);

//变量初始化
$ctr=0;
$tmp='';

//for循环,$i为从0开始,到小于$txt字串长度的整数
for($i=0;$i<strlen($txt);$i++){
//如果$ctr=$encrypt_key的长度,则$ctr清零
$ctr=$ctr==strlen($encrypt_key)?0:$ctr;
//$tmp字串在末尾增加一位,其内容为$txt的第$i位,
//与$encrypt_key的第$ctr+1位取异或。然后$ctr=$ctr+1
$tmp.=$txt[$i]^$encrypt_key[$ctr++];
}

//返回$tmp的值作为结果
return$tmp;

}

/**
*Passport信息(数组)编码函数
*
*@paramarray待编码的数组
*
*@returnstring数组经编码后的字串
*/
functionpassport_encode($array){

//数组变量初始化
$arrayenc=array();

//遍历数组$array,其中$key为当前元素的下标,$val为其对应的值
foreach($arrayas$key=>$val){
//$arrayenc数组增加一个元素,其内容为"$key=经过urlencode()后的$val值"
$arrayenc[]=$key.'='.urlencode($val);
}

//返回以"&"连接的$arrayenc的值(implode),例如$arrayenc=array('aa','bb','cc','dd'),
//则implode('&',$arrayenc)后的结果为”aa&bb&cc&dd"
returnimplode('&',$arrayenc);

}

$returnFlg=implode('',file('http://192.168.0.118:433/Discuz/api/userprofile.php?sign='.$sign.'&'.$urlstr));

echo$returnFlg;
/*
if($returnFlg=="1")
{
header("Location:http://192.168.0.118:433/Discuz/index.php");
}
*/