日期:2012-05-31  浏览次数:20508 次

修改discuz,uchome,ucenter兼容自己开发的通行证
最近稍有接触,修改其中的部分代码,就贡献其中的关键部分吧。

目前discuz的会员注册是在discuz自己的体系中完成,然后post(或者mysql直接操作,此处以post代称)到ucenter的数据库,其中会员密码是md5(md5(真实密码)+首次随机字符sult),memberid由ucenter产生。然后得到改值,保存在discuz。

如果是自己已有通行证系统,产生id,保存密码这部分就在自己的系统完成,然后送回来到ucenter,然后保存到dizcuz。

在uc_center/client.php中加入代码


//cjjer
function uc_user_registerCjjer($uid,$username, $password, $email, $questionid = '', $answer = '') {

    return call_user_func(UC_API_FUNC, 'user', 'register', array('uid'=>$uid,'username'=>$username, 'password'=>$password, 'email'=>$email, 'questionid'=>$questionid, 'answer'=>$answer));
}
function uc_user_updateCjjer($uid,$username, $password, $email, $questionid = '', $answer = '') {
    return call_user_func(UC_API_FUNC, 'user', 'myupdate', array('uid'=>$uid,'username'=>$username, 'password'=>$password, 'email'=>$email, 'questionid'=>$questionid, 'answer'=>$answer));
}


注册的时候就用uc_user_registerCjjer。

在contol/user.php加入代码:

    //    rewrite by cjjer

    function onregister() {
        $this->init_input();
        $username = $this->input('username');
        $myuserid = intval($this->input('uid'));
        $password =  $this->input('password');
        $email = $this->input('email');
        $questionid = $this->input('questionid');
        $answer = $this->input('answer');

        if(    (($status = $this->_check_username($username)) < 0)
            (($status = $this->_check_email($email)) < 0)
            ($status = $_ENV['user']->get_user_by_uid($myuserid))
            ) {
            //开始更新会员资料
            $_ENV['user']->update_user($myuserid,$username, $password, $email, $myuserid, $questionid, $answer);
            return $myuserid;
        }else{
            $uid = $_ENV['user']->add_user($username, $password, $email, $myuserid, $questionid, $answer);
        }
        return $uid;
    }

    function onmyupdate() {
        $this->init_input();
        $username = $this->input('username');
        $myuserid = intval($this->input('uid'));
        $password =  $this->input('password');
        $email = $this->input('email');
        $questionid = $this->input('questionid');
        $answer = $this->input('answer');

        $status = $_ENV['user']->get_user_by_uid($myuserid);
        if(!$status) {
            return -1;
        }