+ Username: | @ |
+ Password: | |
+ Re-type password: | |
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+is_valid)
+ {
+ $registration_backend->init($config);
+ $user = $_POST['username'];
+ $pass = $_POST['password'];
+ $pass2 = $_POST['password2'];
+
+ $ok = true;
+
+ if (!$user)
+ {
+ echo 'Sorry, you didn\'t tell us which username you want! Please go back and try again.
';
+ $ok = false;
+ }
+
+ if($pass !== $pass2)
+ {
+ echo 'The two passwords you typed are not the same, please go back and try more carefully! :-)
';
+ $ok = false;
+ }
+
+ if($ok)
+ {
+ if(!mb_check_encoding($user, 'UTF-8') || !mb_check_encoding($pass, 'UTF-8'))
+ {
+ echo 'Sorry, your browser sent an invalid form entry. Try removing special characters from your username/password.
';
+ echo 'Alternatively please try a different browser and re-submit the form.
';
+ $ok = false;
+ }
+ else
+ {
+ $user = mb_strtolower($user, 'UTF-8');
+ }
+ }
+
+ // Check that username is valid for a JID
+ if ($ok && strlen($user) > 255)
+ {
+ echo 'Sorry, the username you entered is waaaaay too long. Please try something shorter!
';
+ $ok = false;
+ }
+
+ if ($ok)
+ {
+ if (strcspn($user, "\"&'/:<>@".chr(127)) !== strlen($user))
+ {
+ echo 'Sorry, that username contains invalid characters (such as &, <, >, / etc.). Please remove them and try again.
';
+ echo strcspn($user, "\"&'/:<>@".chr(127))." vs ".strlen($user);
+ $ok = false;
+ }
+ else if (strpos($user, chr(255).chr(254)) || strpos($user, chr(255.255)))
+ {
+ echo 'Sorry, that username contains invalid characters. Please remove them and try again.
';
+ $ok = false;
+ }
+ else
+ {
+ $charfreq = array_keys(count_chars($user, 1));
+ if (min($charfreq) <= 32)
+ {
+ echo 'Sorry, that username contains invalid characters. For example you cannot use spaces in a username. Please go back, remove them, and try again.
';
+ $ok = false;
+ }
+ }
+
+ }
+
+ if ($ok && (strlen($pass) < 6))
+ {
+ echo 'Your password isn\'t long enough. It needs to be at least 6 characters long, to make sure that it can\'t be easily guessed. Go back and try again.
';
+ $ok = false;
+ }
+
+ if ($ok)
+ {
+ $backend_message = $registration_backend->validate($user, $pass);
+ if($backend_message)
+ {
+ echo "".htmlentities($backend_message)." Please go back and try again.
";
+ $ok = false;
+ }
+ }
+
+ // Check that username does not already exist
+ if ($ok)
+ {
+ if($registration_backend->exists($user))
+ {
+ echo 'A user with that name already exists, please go back and choose a different username.
';
+ $ok = false;
+ }
+ }
+
+ if ($ok)
+ {
+ $result = $registration_backend->create($user, $pass);
+ if ($result)
+ {
+ echo 'You successfully registered the Jabber ID
'.$_POST["username"].'@'.$config['host'].'
';
+ echo "";
+ echo "
If you haven't already, now is a good time to ";
+ echo "download a client which you can ";
+ echo 'use to log into your new account.
';
+ echo '
Wondering what you can do with your new '.$config['host'].' account? ';
+ echo 'Here are some services at which you can use your Jabber ID:
';
+ echo '
';
+ echo '- identi.ca - Open microblogging service
';
+ echo '- Speeqe - Web-based Jabber chatrooms
';
+ echo '
';
+ echo '
Did you know? Google Talk is one of the many other ';
+ echo 'Jabber-compatible services, which ';
+ echo 'means you can add your Gmail and Google Apps friends directly to your '.ucfirst($config['host']).' contact list!
';
+ echo '
';
+ }
+ else
+ echo 'There was a problem creating your account. If the problem persists, please contact us.
';
+ }
+ $registration_backend->close();
+ }
+ else
+ {
+ echo 'Sorry, the CAPTCHA text you entered was incorrect, please go back and try again.
';
+ if($config['debug'])
+ echo '('.$resp->error.')';
+ }
+}
+?>
+
+
+
+
+