コード例 #1
0
ファイル: ajax-account.php プロジェクト: newnius/quickauth
     }
     if (!isset($_POST['password'])) {
         exit('Invalid request');
     }
     if (strpos($_POST['username'], '@') === true) {
         exit('@ can not be included in username');
     }
     echo reg($_POST['username'], $_POST['email'], $_POST['password']);
     break;
 case 'isNameReged':
     if (isset($_GET['username'])) {
         if (strpos($_GET['username'], '@') === true) {
             echo 'true';
             exit;
         }
         if (is_name_reged($_GET['username'])) {
             echo 'true';
         } else {
             echo 'false';
         }
     } else {
         echo 'Invalid request';
     }
     break;
 case 'isEmailReged':
     if (isset($_GET['email'])) {
         if (is_email_reged($_GET['email'])) {
             echo 'true';
         } else {
             echo 'false';
         }
コード例 #2
0
function Reg($username, $email, $pwd)
{
    if (!ENABLE_REGISTER) {
        return 'Registeration closed';
    }
    if (mb_strlen($username, 'utf8') < 1 || mb_strlen($username, 'utf8') > 12) {
        return 'Username length should <= 12';
    }
    if (strlen($pwd) != 32) {
        return 'Invalid password';
    }
    if (!preg_match("/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)\$/i", $email)) {
        return 'Unacceptable email';
    }
    if (!is_name_reged($username) && !is_email_reged($email)) {
        $salt = rand_string(64);
        $pwd = crypt_pwd($pwd, $salt);
        $auth_key = rand_string();
        $reg_time = time();
        $reg_ip = ip2long(get_ip());
        $sql = "INSERT INTO `account`(`username`, `email`,`password`,`auth_key`, `salt`, `reg_time`, `reg_ip`) VALUES ( ?, ?, ?, ?, ?, ?, ?)";
        $params = array($username, $email, $pwd, $auth_key, $salt, $reg_time, $reg_ip);
        $param_types = 'sssssii';
        $count = (new MysqlDAO())->execute($sql, $params, $param_types);
        if ($count == 0) {
            return 'Unable to signup (errorno:1001)';
        } else {
            if ($count == 1) {
                send_welcome_mail($username, $email, '', $reg_ip);
                return '1';
            } else {
                return 'Unable to signup, sth is wrong with server';
            }
        }
    } else {
        return 'Username or email have been occupied';
    }
}
コード例 #3
0
ファイル: functions-account.php プロジェクト: newnius/jluewu
function Reg($username, $email, $pwd)
{
    $msg = is_name_valid($username);
    if ($msg != '') {
        return $msg;
    }
    $msg = is_email_valid($email);
    if ($msg != '') {
        return $msg;
    }
    if (strlen($pwd) != 32) {
        return '无效的请求';
    }
    if (is_name_reged($username)) {
        return '用户名已被注册';
    }
    if (is_email_reged($email)) {
        return '邮箱已被注册';
    }
    $time = time();
    $ip = ip2long(get_ip());
    $salt = rand_string();
    $pwd = crypt_pwd($pwd, $salt);
    $auth_key = rand_string(32);
    $sql = 'INSERT INTO `ewu_account`(`username`, `email`, `pwd`, `auth_key`, `salt`, `reg_time`, `reg_ip`) VALUES ( ?, ?, ?, ?, ?, ?, ?)';
    $params = array($username, $email, $pwd, $auth_key, $salt, $time, $ip);
    $count = (new MysqlPDO())->execute($sql, $params);
    if ($count == 0) {
        return '服务器繁忙,注册失败 (errno:1001)';
    } else {
        if ($count == 1) {
            send_welcome_mail($username, $email, $ip, process_auth_key($auth_key));
            return '1';
        } else {
            return '服务器繁忙,注册失败(errno:1002)';
        }
    }
}