Example #1
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';
    }
}
Example #2
0
  <meta name="author" content="zolken">
  <meta name="description" content="Resend email to user.">
  <meta name="robots" content="noindex">
  <meta name=”viewport” content=”width=device-width, initial-scale=1″ />
  
  <title>Resend Mail</title>
  
  <link rel="stylesheet" type="text/css" href="../../style/register_theme.css">
  
</head>
<body>
    
    <?php 
if (isset($_GET['id'])) {
    include 'transactional_mail.php';
    if (send_welcome_mail($_GET['id'])) {
        echo '<div id="register_complete" style="display: block;">
                    <h1>Se li acaba d\'enviar un nou correu</h1>
                    <hr>
                    <p>El correu pot trigar entre 1 i 5 minuts a arrivar. Si no l\'ha rebut passat aquest temps, comprovi que no estigui dins la <b>carpeta d\'spam</b>.</p> 
                </div>';
        exit(0);
    }
}
echo '<div id="register_error" style="display: block;">
		<h1>No s\'ha pogut enviar el correu</h1>
		<hr>
		<p>Comprovi que el seu proveïdor de correu no tingui restringit els dominis.</p>
        </div>';
?>
   
Example #3
0
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)';
        }
    }
}
Example #4
0
include '../mysql_connection.php';
$conn = get_connection();
echo $conn->connect_error;
$eencoded = base64_encode($email);
$epass = crypt($password, '$5$rounds=5000$universe' . $universe . '$');
$query = "insert into users(name,email,password,universe,year) values (";
$query .= "'" . base64_encode($name) . "'";
$query .= ",'" . $eencoded . "'";
$query .= ",'" . $epass . "'";
$query .= "," . $universe;
$query .= "," . $year . ");";
/*        Check if user exists        */
$res = $conn->query("select id from users where (name='" . base64_encode($name) . "' or email='" . $eencoded . "') and universe=" . $universe . ";");
if (!$res || $res->num_rows > 0) {
    echo '{"id":0,"mail":0}';
    exit(1);
}
if (!$conn->query($query)) {
    echo '{"id":0,"mail":0}';
    exit(1);
}
$id = $conn->insert_id;
echo '{"id":' . $id . ',';
$conn->close();
/*      Mail        */
include 'transactional_mail.php';
if (send_welcome_mail($id)) {
    echo '"mail":1}';
} else {
    echo '"mail":0}';
}