Title: New User Registration Comment: Sign up new users.

New User Registration

Desired Username:

(maximum 20 characters; numbers and letters only)

Real Name:

Valid E-Mail Address:

(this is only used in case you forget your password)

Password:

Confirm:

(must be at least 6 characters long)

Time Zone:
%timezone%

Don't edit these fields.


my $action = $query->{action} || 'index'; # Are we allowed to sign up? if ($root->{conf}->{users}->{allowregister} != 1) { $root->{content} = "

Registration Disabled

\n\n" . "New user registrations have been disabled on this " . "site."; } else { if ($action eq 'index') { my $tz = &listTimezones(); $root->{content} =~ s/%timezone%/$tz/ig; } if ($action eq 'newuser') { # Collect info. my $user = $query->{username} || ''; $user = &normalize($user); $user = &dirEscape($user); my $nick = $query->{nick} || ''; my $email = $query->{email} || ''; my $pw1 = $query->{pw1} || ''; my $pw2 = $query->{pw2} || ''; my $tz = $query->{timezone} || 'EDT'; my $trap1 = $query->{contact} || ''; my $trap2 = $query->{website} || ''; my $trap3 = $query->{message} || ''; # Validate everything. my @errors = (); if ($trap1 ne '') { push (@errors,"Unknown Error 1."); } if ($trap2 ne 'http://') { push (@errors,"Unknown Error 2."); } if ($trap3 ne '') { push (@errors,"Unknown Error 3."); } if (length $user == 0) { push (@errors,"You must specify a username."); } if (&userExists($user)) { push (@errors,"That username is already " . "taken."); } if ($user =~ /^(admin|root)/i) { # Only the admin can register a username that # begins with admin or root. if (&isAdmin != 1) { push (@errors,"Usernames that begin " . "with 'admin' or 'root' " . "are reserved."); } } if ($user =~ /^(guest|nobody)$/i) { push (@errors,"That username is reserved and " . "cannot be registered."); } if (length $user > 20) { push (@errors,"Your username can only be up to " . "20 characters long."); } if ($user =~ /[^A-Za-z0-9]/i) { push (@errors,"Your username can only contain " . "letters and numbers."); } if (length $pw1 < 6) { push (@errors,"Your password must be at least " . "6 characters long."); } if ($pw1 ne $pw2) { push (@errors,"Your passwords don't match."); } if (scalar(@errors)) { $root->{content} = "

Registration

\n\n" . "Your registration request has " . "failed due to the following " . "errors:\n\n" . ""; } else { # Register the user. my $pass = md5_hex($pw1); &createUser ($user, username => $user, password => $pass, power => 'user', email => $email, timezone => $tz, name => $nick, ); $root->{content} = "

Registration

\n\n" . "Congratulations! You have registered" . " the user $user. " . "You can now sign in."; } } }