好象说用UCENTER也可以,还没试。下面转的
<?php
define('IN_DISCUZ',TRUE);
define('CURSCRIPT', 'logging');
require "./bbs/config.inc.php";
require './bbs/include/global.func.php';//验证码转换的实现
require './bbs/uc_client/client.php';//uc登陆相关
/// 以上为DZ相关
$m=new CMySQL($dbhost,$dbuser,$dbpw,$dbname);
///数据准备
$sid=isset($_COOKIE[$cookiepre."sid"])?$_COOKIE[$cookiepre."sid"]:"";//COOKIE数据:sid,$cookiepre在config.inc.php中定义
if($sid!="")//当cookie中有sid的时候,检测该用户是否已经登陆
{
$SQL="select seccode,uid,username from ".$tablepre."sessions where sid=\"".$_COOKIE[$cookiepre."sid"]."\" limit 1";//验证码
$sess=$m->DoQuery($SQL);
if($sess[0]["username"]!="")//数据库中该sid所对应的用户已经登陆
{
$login=1;
$SQL="select uid,username,email from ".$tablepre."members where uid=".$sess[0]["uid"]." limit 1";
$data=$m->DoQuery($SQL);
$uid=$data[0]["uid"];
$username=$data[0]["username"];
$email=$data[0]["email"];
}
else $login=0;//登陸失敗
}
if(isset($_POST["message"])) //检测是否有数据提交
{
if($username!="")
{
if($message!="")
{
if($code!="")
{
$key=$sess[0]["seccode"];
seccodeconvert($key);
if(strtoupper($key)===strtoupper($code))//这里是验证码检测
{
//... //插入新数据
$SQL="update ".$tablepre."sessions set seccode=0 where sid=\"$sid\""; //清除原有验证码信息
$m->DoQueryNoReturn($SQL);
}
else $error_info="验证码错误!";
}
else $error_info="验证码不能为空!";
}
else
$error_info="回复内容不能为空。";
}
else{ $error_info="未登錄!";$login=0;}
}
else if(isset($_POST["username"])) //检测是否有登陆表单数据提交
{
if($login_user!="")
{
$ucresult = uc_user_login($login_user, $psd);
list($uid,$username,$password,$email)=$ucresult;
if($uid>0)
{
$SQL="update ".$tablepre."sessions set username='$username',uid=$uid where sid='$sid'";//更新_sessions数据表
$m->DoQueryNoReturn($SQL);
$login=1;
}
}
}