コード例 #1
0
 public function ucLogin($username, $password)
 {
     include_once './api/uc_client/client.php';
     //Ucenter 内数据
     $uc_user = uc_user_login($username, $password, 0);
     //关联表内数据
     $uc_user_ref = get_ucenter_user_ref('', $uc_user['0'], '');
     //登录
     if ($uc_user_ref['uid'] && $uc_user_ref['uc_uid'] && $uc_user[0] > 0) {
         return $uc_user_ref['uid'];
     }
     //本地帐号信息
     $tox_user = $this->getLocal($username, $password);
     // 关联表无、UC有、本地无的
     if ($uc_user[0] > 0 && !$tox_user['id']) {
         $uid = $this->register($uc_user[1], $uc_user[1], $uc_user[2], $uc_user[3], '', 1);
         if ($uid <= 0) {
             return A('Ucenter/Member')->showRegError($uid);
         }
         $this->initRoleUser(1, $uid);
         //初始化角色用户
         $result = add_ucenter_user_ref($uid, $uc_user[0], $uc_user[1], $uc_user[3]);
         if (!$result) {
             return '用户不存在或密码错误';
         }
         return $uid;
     }
     // 关联表无、UC有、本地有的
     if ($uc_user[0] > 0 && $tox_user['id'] > 0) {
         $result = add_ucenter_user_ref($tox_user['id'], $uc_user[0], $uc_user[1], $uc_user[3]);
         if (!$result) {
             return '用户不存在或密码错误';
         }
         return $tox_user['id'];
     }
     // 关联表无、UC无、本地有
     if ($uc_user[0] < 0 && $tox_user['id'] > 0) {
         $email = $tox_user['email'] ? $tox_user['email'] : $this->rand_email();
         //写入UC
         $uc_uid = uc_user_register($tox_user['username'], $password, $email, '', '', get_client_ip());
         if ($uc_uid <= 0) {
             return 'UC帐号注册失败,请联系管理员';
         }
         //写入关联表
         if (M('ucenter_user_link')->where(array('uid' => $tox_user['id']))->find()) {
             $result = update_ucenter_user_ref($tox_user['id'], $uc_uid, $tox_user['username'], $email);
         } else {
             $result = add_ucenter_user_ref($tox_user['id'], $uc_uid, $tox_user['username'], $email);
         }
         if (!$result) {
             return '用户不存在或密码错误';
         }
         return $tox_user['id'];
     }
     //关联表无、UC无、本地无的
     return '用户不存在';
 }
コード例 #2
0
 public function ucLogin($username, $password)
 {
     include_once './api/uc_client/client.php';
     //Ucenter 内数据
     $uc_user = uc_user_login($username, $password, 0);
     //关联表内数据
     $uc_user_ref = get_ucenter_user_ref('', $uc_user['0'], '');
     //登录
     if ($uc_user_ref['uid'] && $uc_user_ref['uc_uid'] && $uc_user[0] > 0) {
         return $uc_user_ref['uid'];
     }
     //本地帐号信息
     $tox_user = $this->getLocal($username, $password);
     // 关联表无、UC有、本地无的
     if ($uc_user[0] > 0 && !$tox_user['id']) {
         $uid = $this->register($uc_user[1], $uc_user[1], $uc_user[2], $uc_user[3], '', 1);
         if ($uid <= 0) {
             return A('Ucenter/Member')->showRegError($uid);
         }
         $this->initRoleUser(1, $uid);
         //初始化角色用户
         $result = add_ucenter_user_ref($uid, $uc_user[0], $uc_user[1], $uc_user[3]);
         if (!$result) {
             return L('_USER_DOES_NOT_EXIST_OR_PASSWORD_ERROR_');
         }
         return $uid;
     }
     // 关联表无、UC有、本地有的
     if ($uc_user[0] > 0 && $tox_user['id'] > 0) {
         $result = add_ucenter_user_ref($tox_user['id'], $uc_user[0], $uc_user[1], $uc_user[3]);
         if (!$result) {
             return L('_USER_DOES_NOT_EXIST_OR_PASSWORD_ERROR_');
         }
         return $tox_user['id'];
     }
     // 关联表无、UC无、本地有
     if ($uc_user[0] < 0 && $tox_user['id'] > 0) {
         $email = $tox_user['email'] ? $tox_user['email'] : $this->rand_email();
         //写入UC
         $uc_uid = uc_user_register($tox_user['username'], $password, $email, '', '', get_client_ip());
         if ($uc_uid <= 0) {
             return L('_UC_ACCOUNT_REGISTRATION_FAILED_PLEASE_CONTACT_THE_ADMINISTRATOR_');
         }
         //写入关联表
         if (M('ucenter_user_link')->where(array('uid' => $tox_user['id']))->find()) {
             $result = update_ucenter_user_ref($tox_user['id'], $uc_uid, $tox_user['username'], $email);
         } else {
             $result = add_ucenter_user_ref($tox_user['id'], $uc_uid, $tox_user['username'], $email);
         }
         if (!$result) {
             return L('_USER_DOES_NOT_EXIST_OR_PASSWORD_ERROR_');
         }
         return $tox_user['id'];
     }
     //关联表无、UC无、本地无的
     return L('_USERS_DO_NOT_EXIST_');
 }