summaryrefslogtreecommitdiffstats
path: root/register.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-01-03 01:08:51 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-01-03 01:08:51 +0000
commit959f1e9a9d1eafe3757b5d820b58aaefb8d047e7 (patch)
treec82ee711ee62acad381f25481901a8abc508c55b /register.php
parenta93768353184965727bebde84a7d970beaa8d4bb (diff)
downloadampache-959f1e9a9d1eafe3757b5d820b58aaefb8d047e7.tar.gz
ampache-959f1e9a9d1eafe3757b5d820b58aaefb8d047e7.tar.bz2
ampache-959f1e9a9d1eafe3757b5d820b58aaefb8d047e7.zip
fixed registration to use existing functions... yea I also broke it at the same time.. I know
Diffstat (limited to 'register.php')
-rw-r--r--register.php231
1 files changed, 125 insertions, 106 deletions
diff --git a/register.php b/register.php
index 027dc991..f51e9cdf 100644
--- a/register.php
+++ b/register.php
@@ -30,127 +30,146 @@
$no_session = true;
require_once ("modules/init.php");
-//Captcha
-
-define ("CAPTCHA_INVERSE, 1");
-include ("modules/captcha/captcha.php");
-require ("modules/validatemail/validateEmailFormat.php");
-require ("modules/validatemail/validateEmail.php");
-
/* Check Perms */
if (!conf('allow_public_registration') || conf('demo_mode')) {
access_denied();
}
+/**
+ * These are only needed for this page so they aren't included in init.php
+ * this is for email validation and the cool little graphic
+*/
+require ("modules/validatemail/validateEmailFormat.php");
+require ("modules/validatemail/validateEmail.php");
-$action = scrub_in($_REQUEST['action']);
+/* Don't even include it if we aren't going to use it */
+if (conf('captcha_public_reg')) {
+ define ("CAPTCHA_INVERSE, 1");
+ include ("modules/captcha/captcha.php");
+}
-?>
+/* Show a light header */
-<?php
+$action = scrub_in($_REQUEST['action']);
/* Start switch based on action passed */
switch ($action) {
- case 'add_user':
- // User information has been entered
- // we need to check the database for possible existing username first
- // if username exists, error and say "Please choose a different name."
- // if username does not exist, insert user information into database
- // then allow the user to 'click here to login'
- // possibly by logging them in right then and there with their current info
- // and 'click here to login' would just be a link back to index.php
- if (conf('demo_mode')) { break; }
- $captcha = captcha::check();
- $accept_agreement = scrub_in($_REQUEST['accept_agreement']);
- $fullname = scrub_in($_REQUEST['fullname']);
- $username = scrub_in($_REQUEST['username']);
- $email = scrub_in($_REQUEST['email']);
- $pass1 = scrub_in($_REQUEST['password_1']);
- $pass2 = scrub_in($_REQUEST['password_2']);
-
- if(!isset ($captcha)){
- $GLOBALS['error']->add_error('captcha',_("Error Captcha Required"));
- }
- if (isset ($captcha)){
- if ($captcha) {
- $msg="SUCCESS";
+ case 'add_user':
+ /**
+ * User information has been entered
+ * we need to check the database for possible existing username first
+ * if username exists, error and say "Please choose a different name."
+ * if username does not exist, insert user information into database
+ * then allow the user to 'click here to login'
+ * possibly by logging them in right then and there with their current info
+ * and 'click here to login' would just be a link back to index.php
+ */
+ $accept_agreement = scrub_in($_REQUEST['accept_agreement']);
+ $fullname = scrub_in($_REQUEST['fullname']);
+ $username = scrub_in($_REQUEST['username']);
+ $email = scrub_in($_REQUEST['email']);
+ $pass1 = scrub_in($_REQUEST['password_1']);
+ $pass2 = scrub_in($_REQUEST['password_2']);
+
+ /* If we're using the captcha stuff */
+ if (conf('captcha_public_reg')) {
+ $captcha = captcha::check();
+ if(!isset ($captcha)) {
+ $GLOBALS['error']->add_error('captcha',_("Error Captcha Required"));
+ }
+ if (isset ($captcha)) {
+ if ($captcha) {
+ $msg="SUCCESS";
+ }
+ else {
+ $GLOBALS['error']->add_error('captcha',_("Error Captcha Failed"));
+ }
+ } // end if we've got captcha
+ } // end if it's enabled
+
+ if(conf('user_agreement')) {
+ if(!$accept_agreement) {
+ $GLOBALS['error']->add_error('user_agreement',_("You <U>must</U> accept the user agreement"));
+ }
+ } // if they have to agree to something
+
+ if(!$username) {
+ $GLOBALS['error']->add_error('username',_("You did not enter a username"));
}
- else {
- $GLOBALS['error']->add_error('captcha',_("Error Captcha Failed"));
- }
- }
-
- if(conf('user_agreement')==true){
- if(!$accept_agreement){
- $GLOBALS['error']->add_error('user_agreement',_("You <U>must</U> accept the user agreement"));
+
+ if(!$fullname) {
+ $GLOBALS['error']->add_error('fullname',_("Please fill in your full name (Firstname Lastname)"));
}
- }
-
- if(!$username){
- $GLOBALS['error']->add_error('username',_("You did not enter a username"));
- }
-
- if(!$fullname){
- $GLOBALS['error']->add_error('fullname',_("Please fill in your full name (Firstname Lastname)"));
- }
-
-//Check the mail for correct address formation.
-
- $attempt = 0;
- $max_attempts = 3;
- $response_code = "";
-
- while ( $response_code == "" || strstr( $response_code, "fsockopen error" )) {
- $validate_results = validateEmail( $email );
-
- $response_code = $validate_results[1];
- if($attempt == $max_attempts) break;
- $attempt++;
- }
-
- if ( $validate_results[0] ) {
- $mmsg = "MAILOK";
- }
- else {
- $GLOBALS['error']->add_error('email',_("Error Email address not confirmed<br>$validate_results[1]"));
- }
-// End of mailcheck
- if(!$pass1){
- $GLOBALS['error']->add_error('password',_("You must enter a password"));
- }
-
- if ( $pass1 != $pass2 ) {
- $GLOBALS['error']->add_error('password',_("Your passwords do not match"));
- }
-
- if($GLOBALS['error']->error_state){
- show_user_registration($values);
- break;
- }
-
- $new_user = new_user("$username", "$fullname", "$email", "$pass1");
- if(!$new_user){
- $GLOBALS['error']->add_error('duplicate_user',_("That username already exists"));
- }
- if($GLOBALS['error']->error_state){
- show_user_registration($values);
- break;
- }
-
-break;
- // This is the default action.
- case 'show_add_user':
- default:
- if (conf('demo_mode')) { break; }
- $values = array('type'=>"new_user");
- show_user_registration($values);
- break;
- case 'new_user':
- include("templates/show_new_user.inc");
- break;
-}
+ /* Check the mail for correct address formation. */
+ $attempt = 0;
+ $max_attempts = 3;
+ $response_code = "";
+
+ while ( $response_code == "" || strstr( $response_code, "fsockopen error" )) {
+ $validate_results = validateEmail( $email );
+ $response_code = $validate_results[1];
+ if($attempt == $max_attempts) {
+ break;
+ }
+ $attempt++;
+ }
+
+ if ($validate_results[0]) {
+ $mmsg = "MAILOK";
+ }
+ else {
+ $GLOBALS['error']->add_error('email',_("Error Email address not confirmed<br>$validate_results[1]"));
+ }
+ /* End of mailcheck */
+
+ if(!$pass1){
+ $GLOBALS['error']->add_error('password',_("You must enter a password"));
+ }
+
+ if ( $pass1 != $pass2 ) {
+ $GLOBALS['error']->add_error('password',_("Your passwords do not match"));
+ }
+
+ if (!check_username($username)) {
+ $GLOBALS['error']->add_error('duplicate_user',_("Error Username already exists"));
+ }
+
+ if($GLOBALS['error']->error_state){
+ show_user_registration($values);
+ break;
+ }
+ /* Attempt to create the new user */
+ $access = '0';
+ if (conf('auto_user')) { $access = '5'; }
+ $new_user = $GLOBALS['user']->create($username,$fullname,$email,$pass1,$access);
+ if (!$new_user) {
+ $GLOBALS['error']->add_error('duplicate_user',_("Error: Insert Failed"));
+ show_user_registration($values);
+ break;
+ }
+
+ $user_object = new User($new_user);
+ $user_object->update_validation(str_rand(20));
+
+ $message = 'Your account has been created. However, this forum requires account activation.' .
+ ' An activation key has been sent to the e-mail address you provided. ' .
+ 'Please check your e-mail for further information';
+
+ send_confirmation($username, $fullname, $email, $password, $validation);
+ show_template('style');
+ show_confirmation(_('Registration Complete'),$message,'/login.php');
+ break;
+ case 'new_user':
+ include("templates/show_new_user.inc");
+ break;
+ case 'show_add_user':
+ default:
+ $values = array('type'=>"new_user");
+ show_user_registration($values);
+ break;
+} // end switch on action
?>