Discuz!登录,注册,退出接口.

<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! 6了.网上找了几个现成的接口都不能用,后来看见csdn论坛上面几个人说直接看文档.

文档很详细,照着文档写了个简单

需要配置的地方不多.

1.用户名,密码(如果没有用户就算注册进去了.)

'username' => 'username',
'password' => md5('000000'),
'email' => 'linjin@ine.net.cn',

2.接口操作方式(登录,注册,退出)

$action= 'login'; // 登录,注册
//$action= 'logout'; // 退出

3.Discuz!的URL.

JsGoto("http://127.0.0.1/bbs/api/passport.php".
"?action=$action".
"&auth=".rawurlencode($auth).
"&forward=".rawurlencode($forward).
"&verify=$verify");

4.其它细节Discuz!文档

Discuz! Passport 接口技术文档

http://www.discuz.net/usersguide/advanced_passport.htm#title

<? php

// ///
/*
*
*Passport加密函数
*
*@paramstring等待加密的原字串
*@paramstring私有密匙(用于解密和加密)
*
*@returnstring原字串经过私有密匙加密后的结果
*/
function passport_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编码结果
return base64_encode (passport_key( $tmp , $key ));

}

/* *
*Passport解密函数
*
*@paramstring加密后的字串
*@paramstring私有密匙(用于解密和加密)
*
*@returnstring字串经过私有密匙解密后的结果
*/
function passport_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处理后的密匙
*/
function passport_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数组经编码后的字串
*/
function passport_encode( $array ){

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

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

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

return implode ( ' & ' , $arrayenc );

}

function JsWrite( $msg )
{
echo " <scriptlanguage="javascript"> " ;
echo $msg ;
echo " </script> " ;
}

function JsGoto( $url )
{
$msg = " location.href='$url'; " ;
JsWrite(
$msg );
exit ;
}

$passport_key = '' ;

$member = array
(
' cookietime ' => time () ,
' time ' => time () ,
' username ' => 'username ' ,
' password ' => md5 ( '0000 00 ' ) ,
' email ' => ' linjin@ine.net.cn ' ,
' credits ' => '' ,
' regip ' => '' ,
' regdate ' => '' ,
' msn ' => ''
);


$action = ' login ' ; // 登录,注册
//$action='logout';//退出

$auth = passport_encrypt(passport_encode( $member ) , $passport_key );
$forward = ' http://127.0.0.1/bbs/index.php ' ;
$verify = md5 ( $action . $auth . $forward . $passport_key );

/*
header("Location:http://127.0.0.1/bbs/api/passport.php".
"?action=$action".
"&auth=".rawurlencode($auth).
"&forward=".rawurlencode($forward).
"&verify=$verify");
*/


JsGoto(
" http://127.0.0.1/bbs/api/passport.php " .
" ?action=$action " .
" &auth= " . rawurlencode ( $auth ) .
" &forward= " . rawurlencode ( $forward ) .
" &verify=$verify " );



?>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
论坛软件系统亦称电子公告板(BBS)系统,它伴随社区BBS的流行而成为互联网最重要的应用之一,也逐渐成为网站核心竞争力的标志性体现。2006年7月 CNNIC 发布的最新统计表明,43.2% 的中国网民经常使用论坛/BBS/讨论组,论坛社区应用首次超过即时通讯 IM ,成为仅次于收发Email的互联网基本应用。 Crossday Discuz! Board(以下简称 Discuz!,中国国家版权局著作权登记号 2006SR11895)是康盛创想(北京)科技有限公司(英文简称Comsenz)推出的一套通用的社区论坛软件系统,用户可以在不需要任何编程的基础上,通过简单的设置和安装,在互联网上搭建起具备完善功能、很强负载能力和可高度定制的论坛服务。Discuz! 的基础架构采用世界上最流行的 web 编程组合 PHP+MySQL 实现,是一个经过完善设计,适用于各种服务器环境的高效论坛系统解决方案。 作为国内最大的社区软件及服务提供商,Comsenz旗下的 Discuz! 开发组具有丰富的 web 应用程序设计经验,尤其在论坛产品及相关领域,经过长期创新性开发,掌握了一整套从算法,数据结构到产品安全性方面的领先技术。使得 Discuz! 无论在稳定性,负载能力,安全保障等方面都居于国内外同类产品领先地位。 自2001年6月面世以来,Discuz!已拥有五年以上的应用历史和三十多万网站用户案例,是全球成熟度最高、覆盖率最大的论坛软件系统之一。
以下是Discuz! X的config_global.php配置文件的注释教程: ```php <?php /** * Discuz! X - 配置文件 * * 版权所有 (C) 2001-2019 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * * $Id: config_global.php 36360 2019-11-18 00:28:51Z nemohou $ */ // ---------------------------- CONFIG DB ----------------------------- // /** * 数据库设置 * * type 数据库类型,可选值为 mysql 或 mysqli * server 数据库服务器 * port 数据库端口 * username 数据库用户名 * password 数据库密码 * dbname 数据库名 * pconnect 是否启用持久连接 * charset 数据库字符集,可选值为 gbk, big5, utf8, latin1, etc. * setnames 是否将字符集强制设为 utf8 * tablepre 表名前缀 * dbdebug 是否启用数据库调试模式 */ $_config['db']['1']['dbtype'] = 'mysql'; $_config['db']['1']['dbhost'] = 'localhost'; $_config['db']['1']['dbport'] = '3306'; $_config['db']['1']['dbuser'] = 'root'; $_config['db']['1']['dbpw'] = 'password'; $_config['db']['1']['dbname'] = 'discuz'; $_config['db']['1']['pconnect'] = '0'; $_config['db']['1']['charset'] = 'utf8'; $_config['db']['1']['setnames'] = '1'; $_config['db']['1']['tablepre'] = 'pre_'; $_config['db']['1']['dbdebug'] = 'false'; // -------------------------- CONFIG MEMORY --------------------------- // /** * 内存变量缓存设置 * * type 缓存类型,可选值为 filecache 或 memcache 或 apc * ttl 缓存失效时间,单位为秒 * prefix 缓存前缀,建议修改,避免同服务器中的程序引起冲突 * servers memcache 缓存服务器地址和端口,可指定多个,格式为数组 */ $_config['memory']['prefix'] = 'discuz_'; $_config['memory']['eaccelerator'] = false; $_config['memory']['apc'] = false; $_config['memory']['xcache'] = false; $_config['memory']['file']['server'] = array(); $_config['memory']['memcache']['server'] = array( array('127.0.0.1', 11211, 1), // 第一个参数为 memcache 服务器的地址,第二个参数为端口,第三个参数为权重,用于负载均衡,默认为1 ); // ----------------------------- CONFIG CACHE --------------------------- // /** * 数据缓存设置 * * type 缓存类型,可选值为 filecache 或 memcache 或 apc * ttl 缓存失效时间,单位为秒 * prefix 缓存前缀,建议修改,避免同服务器中的程序引起冲突 * filecache 设置缓存的目录,仅对 filecache 缓存有效 * servers memcache 缓存服务器地址和端口,可指定多个,格式为数组 * compress 是否启用 memcache 的压缩功能 */ $_config['cache']['type'] = 'filecache'; $_config['cache']['file']['server'] = array( array('localhost', 11211, 1), ); $_config['cache']['memcache']['server'] = array( array('localhost', 11211, 1), ); $_config['cache']['apc'] = false; $_config['cache']['ttl'] = 0; $_config['cache']['prefix'] = 'discuz_'; $_config['cache']['file']['dir'] = './data/cache/'; $_config['cache']['memcache']['compress'] = false; // ----------------------------- CONFIG SMTP --------------------------- // /** * 邮件设置 * * maildefault 默认的邮件发送方式,可选值为 smtp 或 sendmail * smtp 以下 SMTP 设置仅在 maildefault 为 smtp 时有效 * server SMTP 服务器地址 * port SMTP 服务器端口 * auth 是否启用 SMTP 认证,可选值为 true 或 false * username SMTP 服务器用户名 * password SMTP 服务器密码 * sendmail 以下 Sendmail 设置仅在 maildefault 为 sendmail 时有效 * server Sendmail 服务器地址 * sendmail_path Sendmail 程序路径 * * 注意:不同的邮件发送方式对应的设置选项不同,具体请参见官方文档 */ $_config['mail']['maildefault'] = 'smtp'; $_config['mail']['smtp']['server'] = 'smtp.exmail.qq.com'; $_config['mail']['smtp']['port'] = '25'; $_config['mail']['smtp']['auth'] = '1'; $_config['mail']['smtp']['username'] = 'admin@example.com'; $_config['mail']['smtp']['password'] = 'password'; $_config['mail']['sendmail']['server'] = '/usr/sbin/sendmail'; $_config['mail']['sendmail']['sendmail_path'] = ''; // ----------------------------- CONFIG SECURITY --------------------------- // /** * 安全设置 * * authkey 论坛加密密钥,建议修改,长度为 64 个字符 * cookiepre cookie 前缀,建议修改,避免同服务器中的程序引起冲突 * cachelist 缓存前缀列表,建议修改,避免同服务器中的程序引起冲突 * attackevasive 是否启用防抵制攻击功能,可选值为 0、1、2、3 或 4 * 0 表示关闭防抵制攻击功能 * 1 表示启用 cookie 刷新方式防抵制攻击功能 * 2 表示启用限制代理访问功能防抵制攻击功能 * 3 表示启用 cookie 刷新与限制代理访问两种方式的防抵制攻击功能 * 4 表示启用加强版防抵制攻击功能 * 注意:启用加强版防抵制攻击功能后,可能会影响网站的访问速度 * admincp_allow_ip 允许访问后台的 IP 地址列表,多个 IP 之间用英文逗号隔开 * admincp_check_ip 是否启用后台 IP 验证功能,可选值为 0 或 1 * admincp_cpsession 是否启用后台 session 验证功能,可选值为 0 或 1 */ $_config['security']['authkey'] = '1234567890123456789012345678901234567890123456789012345678901234'; $_config['security']['cookiepre'] = 'discuz_'; $_config['security']['cachelist'] = ''; $_config['security']['attackevasive'] = '0'; $_config['security']['admincp_allow_ip'] = ''; $_config['security']['admincp_check_ip'] = '1'; $_config['security']['admincp_cpsession'] = '1'; // ----------------------------- CONFIG SYSTEM --------------------------- // /** * 系统设置 * * debug 是否启用调试模式,可选值为 true 或 false * cookie_domain cookie 作用域 * cookie_path cookie 作用路径 * attachdir 附件上传目录,相对于论坛根目录的路径 * attachurl 附件 URL 地址 * attachimgpost 是否允许在帖子中显示图片附件,可选值为 0 或 1 * attachrefcheck 是否检查附件引用,可选值为 0 或 1 * attachsave 是否在服务器上保存上传的附件,可选值为 0 或 1 * attachimgmaxsize 图片类附件上传大小,单位为字节 * attachimgthumb 是否生成缩略图,可选值为 0 或 1 * attachimgquality 缩略图质量,取值范围为 1-100 * attachimgwatermark 是否添加水印,可选值为 0 或 1 * attachimgwatermarktype 水印类型,可选值为 text、image 或 none * attachimgwatermarktext 水印文字,当水印类型为 text 时有效 * attachimgwatermarktrans 水印透明度,取值范围为 1-100,当水印类型为 text 时有效 * attachimgwatermarkfile 水印图片文件名,当水印类型为 image 时有效 * attachimgwatermarkpos 水印位置,可选值为 1-9,当水印类型为 image 时有效 * refererhotlink 是否开启防盗链功能,可选值为 0 或 1 * hotlink_protect_key 防盗链密钥,如果不设置,则系统自动生成一个密钥 */ $_config['debug'] = false; $_config['cookie']['cookie_domain'] = ''; $_config['cookie']['cookie_path'] = '/'; $_config['attachdir'] = './data/attachment'; $_config['attachurl'] = 'attachment/'; $_config['attachimgpost'] = '1'; $_config['attachrefcheck'] = '1'; $_config['attachsave'] = '1'; $_config['attachimgmaxsize'] = '2048000'; $_config['attachimgthumb'] = '1'; $_config['attachimgquality'] = '80'; $_config['attachimgwatermark'] = '1'; $_config['attachimgwatermarktype'] = 'text'; $_config['attachimgwatermarktext'] = 'Discuz!'; $_config['attachimgwatermarktrans'] = '50'; $_config['attachimgwatermarkfile'] = ''; $_config['attachimgwatermarkpos'] = '9'; $_config['refererhotlink'] = '0'; $_config['hotlink_protect_key'] = ''; // ----------------------------- CONFIG OUTPUT --------------------------- // /** * 输出设置 * * output_gzip 是否启用 Gzip 压缩输出,可选值为 0 或 1 * output_charset 输出页面字符集,可选值为 gb2312、gbk、big5、utf-8 或 iso-8859-1 * output_language 输出页面语言,可选值为 en、zh-cn、zh-tw * output_encoding 输出页面编码格式,可选值为 xml、html、xhtml */ $_config['output']['gzip'] = '0'; $_config['output']['charset'] = 'utf-8'; $_config['output']['language'] = 'zh-cn'; $_config['output']['encoding'] = 'html'; ``` 以上就是Discuz! X的config_global.php配置文件的注释教程,希望能够帮助到你。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值