<?php
error_reporting(E_ALL);$path_bbs="discuz/";//请修改为你的论坛的相对路径
$check_username="admin";//测试时这个用户名必须在论坛里也存在
$check_password="admin";
define('IN_DISCUZ', TRUE);//为了包含discuz下的文件这个必须定义
require_once "$path_bbs/config.inc.php";//获得论坛数据库的配置
require_once "$path_bbs/include/db_mysql.class.php";if(@$_GET[act]=="logout"){
    foreach ($_COOKIE as $key => $value) {
        setcookie($key,'',time() - 3600,$cookiepath,$cookiedomain,0);             
            header("Location:".$_SERVER['PHP_SELF']);          
    }
}
if(isset($_POST["submit"])){//检查是否点击了提交按钮
    $username=trim($_POST['username']);
    $pwd=trim($_POST['password']);
    //主站验证登陆,为简单起见,这里只作简单的示范
    if($username==$check_username && $pwd==$check_password){//测试时这个用户名必须在论坛里也存在
        $db = new dbstuff;
        $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);//$dbhost,$dbuser,$dbpw,$dbname,$pconnect是在bbs/config.inc.php里定义的变量
        $sql="select * from {$tablepre}members where username='$username'";
        $rs = $db->query($sql);
        if($dzmember = $db->fetch_array($rs)){
                 setcookie('username',$username,time()+3600,$cookiepath,$cookiedomain,0);//设置主站自身的cookie
            setcookie("{$tablepre}sid",'',time() - 3600,$cookiepath,$cookiedomain,0);//让discuz的sid过期是为了让discuz重新分配一个新的sid
            setcookie("{$tablepre}auth", authcode("$dzmember[password]\t$dzmember[secques]\t$dzmember[uid]", 'ENCODE'),time()+3600,$cookiepath,$cookiedomain,0);//$cookiepath和$cookiedomainbbs/config.inc.php里定义的变量
            header("Location:".$_SERVER['REQUEST_URI']);
        }
    }
}//下面这个函数是discuz的用户cookie编码函数,已修改,原型在$path_bbs/include/global.func.php
function authcode($string, $operation) {
    global $_SERVER, $_DCACHE,$path_bbs;
    require_once "$path_bbs/forumdata/cache/cache_settings.php";//需要获取论坛的authkey
    $discuz_auth_key = md5($_DCACHE['settings']['authkey'].$_SERVER['HTTP_USER_AGENT']);
    $coded = '';
    $keylength = strlen($discuz_auth_key);
    $string = $operation == 'DECODE' ? base64_decode($string) : $string;
    for($i = 0; $i < strlen($string); $i += $keylength) {
        $coded .= substr($string, $i, $keylength) ^ $discuz_auth_key;
    }
    $coded = $operation == 'ENCODE' ? str_replace('=', '', base64_encode($coded)) : $coded;
    return $coded;
}
?>
<?php
if(@$_COOKIE['username']==''){
?>
<form action="" method="POST">
用户名:<input name="username">测试用户名为admin,请更改为你的用户名<br>
密码:<input type="password" name="password">测试密码为123456<br>
<input type="submit" name="submit" value="测试">
</form>
<?php
}
else echo("".$_COOKIE['username']."登陆成功,<a href='{$path_bbs}index.php' target=_blank>请到论坛检查登陆</a><br><a href='?act=logout'>退出登陆</a> ");
?>这是我在网上下的一个主站与DISCUZ整合的通行证,但登陆discuz没有反映,没有登陆过一样,
我的config.inc.php文件是这样的
        $cookiepre = 'cdb_';                        // cookie 前缀
        $cookiedomain = '';                         // cookie 作用域
        $cookiepath = '/';                        // cookie 作用路径