Beispiel #1
0
            if (strlen($username) < 6) {
                showmessage('用户名至少要6个字符(即2个中文 或 6个英文),请修改', dreferer(), 5);
            }
            if (strlen($username) > 24) {
                showmessage('用户名过长,请修改', dreferer(), 5);
            }
            $un = strtolower($username);
            if (strexists($un, 'admin') || strexists($un, 'guanli')) {
                showmessage('用户名不和谐,请修改', dreferer(), 5);
            }
            $user = DB::fetch_first("SELECT * FROM member WHERE username='******'");
            if ($user) {
                showmessage('用户名已经存在', 'member.php');
            }
            HOOK::run('before_register');
            $uid = do_register($username, $_POST['password'], $email);
            do_login($uid);
            HOOK::run('register_finish', $uid);
            showmessage("注册成功,您的用户名是 <b>{$username}</b> 记住了哦~!", dreferer(), 3);
        }
    }
    header('Location: member.php');
    exit;
} elseif ($_POST) {
    if ($_POST['username'] && $_POST['password']) {
        $username = daddslashes($_POST['username']);
        $un = strtolower($username);
        if (strlen($username) > 24) {
            showmessage('用户名过长,请修改', dreferer(), 5);
        }
        $user = DB::fetch_first("SELECT * FROM member WHERE username='******' OR email='{$username}'");
<?php

if (is_logged_in()) {
    redirect();
}
if (is_post()) {
    if (do_register()) {
        redirect("login");
    }
}
include_header(array("title" => "registration"));
?>
<div class="row">
    <div class="col-md-4 col-md-offset-4">
        <form id="login-form" method="post">
            <div class="form-group">
                <label for="inputName" class="sr-only">name</label>
                <input type="text" name="name" id="inputName" class="form-control" placeholder="name"
                       value="<?php 
echo isset($_POST["name"]) ? plain($_POST["name"]) : "";
?>
" required autofocus>
            </div>
            <div class="form-group">
                <label for="inputEmail" class="sr-only">email address</label>
                <input type="email" name="email" id="inputEmail" class="form-control" placeholder="email address"
                       value="<?php 
echo isset($_POST["email"]) ? plain($_POST["email"]) : "";
?>
" required>
            </div>
Beispiel #3
0
function debo_mostrar_captcha()
{
    global $globals;
    // Sólo mostramos el captcha si se ha registrado con éxito ya esta ip en las últimas 24 horas
    // o si se han fallado 3 veces durante el registro en las últimas 24 horas
    return log_get("register_ok", ip2long($globals['ip']), 0, 24 * 60 * 60) > 0 || log_get("register_fail", ip2long($globals['ip']), 0, 24 * 60 * 60) >= 3;
}
$mostrar_captcha = debo_mostrar_captcha();
// Cuando pulsamos submit del formulario entramos por aquí...
if (array_key_exists('doRegister', $_POST)) {
    // Filtramos todos los campos del formulario, para evitar código malicioso
    foreach ($_POST as $key => $value) {
        $data[$key] = filter($value);
    }
    // Validamos los datos, y si son correctos creamos el usuario
    do_register();
    if (!empty($hasError)) {
        log_insert("register_fail", ip2long($globals['ip']));
        $mostrar_captcha = debo_mostrar_captcha();
    }
}
get_header("register.php", $mostrar_captcha);
escribir_titulo("Regístrate", "Entra en la comunidad");
// Mostramos una caja con los errores encontrados tras hacer submit
escribir_resultado_validaciones($hasError);
?>
 

         <div class="contentArea">

            <div class="half-page separador">
Beispiel #4
0
<?php

if (!defined('IN_TBB')) {
    die;
}
if ($s[logged_in] == 1) {
    print 'You already have an account.<br><a href=\'index.php\'>Return to the main page</a>';
} else {
    // if it returns a non-blank string, it's an error
    // if it returns true (check with === not ==) the account has been created successfully
    // if it returns nothing, just show the form
    $result = do_register();
    if ($result === true) {
        print 'Your account has been created!<br>You can now log in with the username and password you entered.<br><a href=\'index.php?m=login\'>Return to the login page</a>';
    } else {
        if ($result != '') {
            print '<b>The following errors occurred while creating your account:<br>' . $result . '</b><hr>';
        }
        ?>
<form action='index.php?m=register' method='post'>
<b>Username:</b> <i>max. 30 characters</i><br>
<input type='text' size='30' maxlength='30' name='un' value='' class='textentry'><br>
<b>Password:</b> <i>min. 6 characters, max. 30 characters</i><br>
<input type='password' size='30' maxlength='30' name='pw' value='' class='textentry'><br>
<b>Retype your password:</b><br>
<input type='password' size='30' maxlength='30' name='retypepw' value='' class='textentry'><br>
<b>Email address:</b><br>
<input type='text' size='30' maxlength='80' name='email' value='' class='textentry'><br>
<input type='submit' name='reg' value='Register' class='button'>
</form>
<?php