Exemple #1
0
}
$db = new MySQL($log);
if ($mysqli = $db->openDB()) {
    $user = new User($mysqli, $log);
    $invitation = new Invitation($mysqli, $log);
    if ($user->getUserByName($username)) {
        $res['reason'] = '用户已存在!';
        $db->closeDB();
        die(json_encode($res));
    }
    if ($user->getUserByMail($email)) {
        $res['reason'] = '邮箱已被使用!';
        $db->closeDB();
        die(json_encode($res));
    }
    $inv_id = $invitation->vilidateCode($invitation_code);
    if ($inv_id) {
        $user->username = $username;
        $user->password = hash('sha256', $password_1);
        $user->email = $email;
        $user->type = 3;
        //普通用户
        $user->b_send = 1;
        //发送邮件
        $user->status = 2;
        //未激活状态
        $uid = $user->addUser();
        if ($uid > 0) {
            $invitation->setRegister($inv_id, $uid);
            //生成邮件验证码
            $val_code = $invitation->genEmailValidateCode($uid);