b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_register.disp.php - 147 lines - 5623 bytes - Text - Print

Description: This file implements the register form

   1  <?php
   2  /**
   3   * This file implements the register form
   4   *
   5   * This file is not meant to be called directly.
   6   *
   7   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}.
   8   *
   9   * @package evocore
  10   *
  11   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  12   * @author asimo: Evo Factory / Attila Simo
  13   *
  14   * @version $Id: _register.disp.php 6136 2014-03-08 07:59:48Z manuel $
  15   */
  16  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  17  
  18  load_class( 'regional/model/_country.class.php', 'Country' );
  19  
  20  global $Settings, $Plugins;
  21  
  22  global $Blog, $rsc_path, $rsc_url, $dummy_fields;
  23  
  24  if( is_logged_in() )
  25  { // if a user is already logged in don't allow to register
  26      echo '<p>'.T_('You are already logged in').'</p>';
  27      return;
  28  }
  29  
  30  if( ! $Settings->get('newusers_canregister') )
  31  {
  32      echo '<p>'.T_('User registration is currently not allowed.').'</p>';
  33      return;
  34  }
  35  
  36  // Save trigger page
  37  $session_registration_trigger_url = $Session->get( 'registration_trigger_url' );
  38  if( empty( $session_registration_trigger_url/*$Session->get( 'registration_trigger_url' )*/ ) && isset( $_SERVER['HTTP_REFERER'] ) )
  39  {    // Trigger page still is not defined
  40      $Session->set( 'registration_trigger_url', $_SERVER['HTTP_REFERER'] );
  41  }
  42  
  43  $login = param( $dummy_fields[ 'login' ], 'string', '' );
  44  $email = param( $dummy_fields[ 'email' ], 'string', '' );
  45  $firstname = param( 'firstname', 'string', '' );
  46  $gender = param( 'gender', 'string', false );
  47  $source = param( 'source', 'string', 'register form' );
  48  $redirect_to = param( 'redirect_to', 'url', '' );
  49  
  50  if( $register_user = $Session->get('core.register_user') )
  51  {    // Get an user data from predefined session (after adding of a comment)
  52      $login = preg_replace( '/[^a-z0-9 ]/i', '', $register_user['name'] );
  53      $login = str_replace( ' ', '_', $login );
  54      $login = substr( $login, 0, 20 );
  55      $email = $register_user['email'];
  56  
  57      $Session->delete( 'core.register_user' );
  58  }
  59  
  60  // set secure htsrv url with the same domain as the request has
  61  $secure_htsrv_url = get_secure_htsrv_url();
  62  
  63  $Form = new Form( $secure_htsrv_url.'register.php', 'register_form', 'post' );
  64  
  65  $Form->add_crumb( 'regform' );
  66  $Form->hidden( 'inskin', true );
  67  $Form->hidden( 'blog', $Blog->ID );
  68  
  69  // disp register form
  70  $Form->begin_form( 'bComment' );
  71  
  72  $Plugins->trigger_event( 'DisplayRegisterFormBefore', array( 'Form' => & $Form, 'inskin' => true ) );
  73  
  74  $Form->hidden( 'action', 'register' );
  75  $Form->hidden( 'source', $source );
  76  $Form->hidden( 'redirect_to', $redirect_to );
  77  
  78  $Form->begin_field();
  79  $Form->text_input( $dummy_fields[ 'login' ], $login, 22, T_('Login'), T_('Choose an username.'), array( 'maxlength' => 20, 'class' => 'input_text', 'required' => true, 'input_suffix' => ' <span id="login_status"></span>' ) );
  80  $Form->end_field();
  81  
  82  $Form->begin_field();
  83  $Form->password_input( $dummy_fields[ 'pass1' ], '', 18, T_('Password'), array( 'note'=>T_('Choose a password.'), 'maxlength' => 70, 'class' => 'input_text', 'required'=>true ) );
  84  $Form->password_input( $dummy_fields[ 'pass2' ], '', 18, '', array( 'note'=>T_('Please type your password again.'), 'maxlength' => 70, 'class' => 'input_text', 'required'=>true ) );
  85  $Form->end_field();
  86  
  87  $Form->begin_field();
  88  $Form->text_input( $dummy_fields[ 'email' ], $email, 50, T_('Email'), '<br />'.T_('We respect your privacy. Your email will remain strictly confidential.'),
  89                  array( 'maxlength'=>255, 'class'=>'input_text wide_input', 'required'=>true ) );
  90  
  91  $registration_require_country = (bool)$Settings->get('registration_require_country');
  92  
  93  if( $registration_require_country )
  94  { // country required
  95      $CountryCache = & get_CountryCache();
  96      $Form->select_country( 'country', param( 'country', 'integer', 0 ), $CountryCache, T_('Country'), array('allow_none'=>true, 'required'=>true) );
  97  }
  98  
  99  $registration_require_firstname = (bool)$Settings->get('registration_require_firstname');
 100  
 101  if( $registration_require_firstname )
 102  { // firstname required
 103      $Form->begin_field();
 104      $Form->text_input( 'firstname', $firstname, 18, T_('First name'), T_('Your real first name.'), array( 'maxlength' => 50, 'class' => 'input_text', 'required' => true ) );
 105      $Form->end_field();
 106  }
 107  
 108  $registration_require_gender = $Settings->get( 'registration_require_gender' );
 109  if( $registration_require_gender != 'hidden' )
 110  { // Display a gender field if it is not hidden
 111      $Form->radio_input( 'gender', $gender, array(
 112                  array( 'value' => 'M', 'label' => T_('A man') ),
 113                  array( 'value' => 'F', 'label' => T_('A woman') ),
 114              ), T_('I am'), array( 'required' => $registration_require_gender == 'required' ) );
 115  }
 116  
 117  if( $Settings->get( 'registration_ask_locale' ) )
 118  { // ask user language
 119      $locale = 'en_US';
 120      $Form->select( 'locale', $locale, 'locale_options_return', T_('Locale'), T_('Preferred language') );
 121  }
 122  $Form->end_field();
 123  
 124  $Form->end_fieldset();
 125  
 126  $Plugins->trigger_event( 'DisplayRegisterFormFieldset', array( 'Form' => & $Form, 'inskin' => true ) );
 127  
 128  // Submit button:
 129  $submit_button = array( array( 'name'=>'register', 'value'=>T_('Register my account now!'), 'class'=>'search', 'style'=>'font-size: 120%' ) );
 130  
 131  $Form->buttons_input($submit_button);
 132  
 133  echo '<div class="login_actions" style="margin: 1em 0 1ex">';
 134  echo '<strong><a href="'.get_login_url( $source, $redirect_to).'">&laquo; '.T_('Already have an account... ?').'</a></strong>';
 135  echo '</div>';
 136  
 137  $Form->end_form();
 138  
 139  echo '<div class="form_footer_notes">'.sprintf( T_('Your IP address: %s'), $Hit->IP ).'</div>';
 140  
 141  // Display javascript password strength indicator bar
 142  display_password_indicator();
 143  
 144  // Display javascript login validator
 145  display_login_validator();
 146  
 147  ?>

title

Description

title

Description

title

Description

title

title

Body