refactor rego in preparation for openid import
This commit is contained in:
parent
93c33f0eb3
commit
f9497bcb95
|
@ -44,14 +44,11 @@ function register_post(&$a) {
|
||||||
|
|
||||||
$err = '';
|
$err = '';
|
||||||
|
|
||||||
// TODO fix some of these regex's for int'l/utf-8.
|
|
||||||
|
|
||||||
if(! valid_email($email))
|
|
||||||
$err .= t(' Not a valid email address.');
|
|
||||||
if(strlen($username) > 48)
|
if(strlen($username) > 48)
|
||||||
$err .= t(' Please use a shorter name.');
|
$err .= t('Please use a shorter name.') . EOL;
|
||||||
if(strlen($username) < 3)
|
if(strlen($username) < 3)
|
||||||
$err .= t(' Name too short.');
|
$err .= t('Name too short.') . EOL;
|
||||||
|
|
||||||
// I don't really like having this rule, but it cuts down
|
// I don't really like having this rule, but it cuts down
|
||||||
// on the number of auto-registrations by Russian spammers
|
// on the number of auto-registrations by Russian spammers
|
||||||
|
@ -63,23 +60,28 @@ function register_post(&$a) {
|
||||||
$loose_reg = get_config('system','no_regfullname');
|
$loose_reg = get_config('system','no_regfullname');
|
||||||
|
|
||||||
if((! $loose_reg) && (! preg_match($pat,$username)))
|
if((! $loose_reg) && (! preg_match($pat,$username)))
|
||||||
$err .= t(' That doesn\'t appear to be your full name.');
|
$err .= t('That doesn\'t appear to be your full name.') . EOL;
|
||||||
|
|
||||||
if(! allowed_email($email))
|
if(! allowed_email($email))
|
||||||
$err .= t(' Your email domain is not among those allowed on this site.');
|
$err .= t('Your email domain is not among those allowed on this site.') . EOL;
|
||||||
|
|
||||||
|
if(! valid_email($email))
|
||||||
|
$err .= t('Not a valid email address.') . EOL;
|
||||||
|
|
||||||
|
|
||||||
|
$nickname = $_POST['nickname'] = strtolower($nickname);
|
||||||
|
|
||||||
$nickname = strtolower($nickname);
|
|
||||||
if(! preg_match("/^[a-z][a-z0-9\-\_]*$/",$nickname))
|
if(! preg_match("/^[a-z][a-z0-9\-\_]*$/",$nickname))
|
||||||
$err .= t(' Your "nickname" can only contain "a-z", "0-9", "-", and "_", and must also begin with a letter.');
|
$err .= t('Your "nickname" can only contain "a-z", "0-9", "-", and "_", and must also begin with a letter.') . EOL;
|
||||||
$r = q("SELECT `uid` FROM `user`
|
$r = q("SELECT `uid` FROM `user`
|
||||||
WHERE `nickname` = '%s' LIMIT 1",
|
WHERE `nickname` = '%s' LIMIT 1",
|
||||||
dbesc($nickname)
|
dbesc($nickname)
|
||||||
);
|
);
|
||||||
if(count($r))
|
if(count($r))
|
||||||
$err .= t(' Nickname is already registered. Please choose another.');
|
$err .= t('Nickname is already registered. Please choose another.') . EOL;
|
||||||
|
|
||||||
if(strlen($err)) {
|
if(strlen($err)) {
|
||||||
notice( $err . EOL );
|
notice( $err );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,11 +308,24 @@ function register_content(&$a) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$username = ((x($_POST,'username')) ? $_POST['username'] : ((x($_GET,'username')) ? $_GET['username'] : ''));
|
||||||
|
$email = ((x($_POST,'email')) ? $_POST['email'] : ((x($_GET,'email')) ? $_GET['email'] : ''));
|
||||||
|
$nickname = ((x($_POST,'nickname')) ? $_POST['nickname'] : ((x($_GET,'nickname')) ? $_GET['nickname'] : ''));
|
||||||
|
|
||||||
$o = load_view_file("view/register.tpl");
|
$o = load_view_file("view/register.tpl");
|
||||||
$o = replace_macros($o, array(
|
$o = replace_macros($o, array(
|
||||||
|
'$regtitle' => t('Registration'),
|
||||||
'$registertext' =>((x($a->config,'register_text'))
|
'$registertext' =>((x($a->config,'register_text'))
|
||||||
? '<div class="error-message">' . $a->config['register_text'] . '</div>'
|
? '<div class="error-message">' . $a->config['register_text'] . '</div>'
|
||||||
: "" ),
|
: "" ),
|
||||||
|
'$namelabel' => t('Your Full Name (e.g. Joe Smith): '),
|
||||||
|
'$addrlabel' => t('Your Email Address: '),
|
||||||
|
'$nickdesc' => t('Choose a profile nickname. This must begin with a text character. Your global profile locator will then be \'<strong>nickname@$sitename</strong>\'.'),
|
||||||
|
'$nicklabel' => t('Choose a nickname: '),
|
||||||
|
'$regbutt' => t('Register'),
|
||||||
|
'$username' => $username,
|
||||||
|
'$email' => $email,
|
||||||
|
'$nickname' => $nickname,
|
||||||
'$sitename' => $a->get_hostname()
|
'$sitename' => $a->get_hostname()
|
||||||
));
|
));
|
||||||
return $o;
|
return $o;
|
||||||
|
|
|
@ -1,36 +1,34 @@
|
||||||
<h3>Registration</h3>
|
<h3>$regtitle</h3>
|
||||||
|
|
||||||
<form action="register" method="post" >
|
<form action="register" method="post" >
|
||||||
|
|
||||||
$registertext
|
$registertext
|
||||||
|
|
||||||
<div id="register-name-wrapper" >
|
<div id="register-name-wrapper" >
|
||||||
<label for="register-name" id="label-register-name" >Your Full Name (e.g. Joe Smith): </label>
|
<label for="register-name" id="label-register-name" >$namelabel</label>
|
||||||
<input type="text" maxlength="60" size="32" name="username" id="register-name" value="" >
|
<input type="text" maxlength="60" size="32" name="username" id="register-name" value="$username" >
|
||||||
</div>
|
</div>
|
||||||
<div id="register-name-end" ></div>
|
<div id="register-name-end" ></div>
|
||||||
|
|
||||||
|
|
||||||
<div id="register-email-wrapper" >
|
<div id="register-email-wrapper" >
|
||||||
<label for="register-email" id="label-register-email" >Your Email Address: </label>
|
<label for="register-email" id="label-register-email" >$addrlabel</label>
|
||||||
<input type="text" maxlength="60" size="32" name="email" id="register-email" value="" >
|
<input type="text" maxlength="60" size="32" name="email" id="register-email" value="$email" >
|
||||||
</div>
|
</div>
|
||||||
<div id="register-email-end" ></div>
|
<div id="register-email-end" ></div>
|
||||||
|
|
||||||
<p id="register-nickname-desc" >
|
<p id="register-nickname-desc" >$nickdesc</p>
|
||||||
Choose a profile nickname. This must begin with a text character.
|
|
||||||
Your global profile locator will then be '<strong>nickname@$sitename</strong>'.
|
|
||||||
</p>
|
|
||||||
<div id="register-nickname-wrapper" >
|
<div id="register-nickname-wrapper" >
|
||||||
<label for="register-nickname" id="label-register-nickname" >Choose a nickname: </label>
|
<label for="register-nickname" id="label-register-nickname" >$nicklabel</label>
|
||||||
<input type="text" maxlength="60" size="32" name="nickname" id="register-nickname" value="" ><div id="register-sitename">@$sitename</div>
|
<input type="text" maxlength="60" size="32" name="nickname" id="register-nickname" value="$nickname" ><div id="register-sitename">@$sitename</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="register-nickname-end" ></div>
|
<div id="register-nickname-end" ></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id="register-submit-wrapper">
|
<div id="register-submit-wrapper">
|
||||||
<input type="submit" name="submit" id="register-submit-button" value="Register" />
|
<input type="submit" name="submit" id="register-submit-button" value="$regbutt" />
|
||||||
</div>
|
</div>
|
||||||
<div id="register-submit-end" ></div>
|
<div id="register-submit-end" ></div>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue